package server import ( "context" http "net/http" "time" "github.com/gorilla/mux" ) type AppServer struct { router *mux.Router httpServer *http.Server } func NewServer(router *mux.Router) *AppServer { port := "8080" httpServer := &http.Server{ Addr: ":" + port, Handler: router, ReadTimeout: 15 * time.Second, WriteTimeout: 15 * time.Second, IdleTimeout: 60 * time.Second, } server := &AppServer{ router: router, httpServer: httpServer, } return server } func (s *AppServer) Start() error { return s.httpServer.ListenAndServe() } func (s *AppServer) Stop(ctx context.Context) { s.httpServer.Shutdown(ctx) }