To initialize the server when run on specific port
packagemainimport ("golang-playground/controller""log""os""os/signal""syscall""github.com/joho/godotenv")funcmain() { err := godotenv.Load()if err !=nil { log.Println("Error loading .env file") } controller := controller.NewInternalController()// open the new thread to run the server instead of blocking the main threadgofunc() {if err := controller.Run("8080"); err !=nil { log.Fatalf("Failed to start server: %v", err) } }() quit :=make(chanos.Signal, 1) signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM)<-quit}
Controller
To declare each api end point and applied middleware
Middleware
To declare the middleware to intercept the request before passing to the controller