feat: ServerMux to gorilla/mux, time route

This commit is contained in:
2025-11-22 23:25:00 +03:00
parent 51f30b516e
commit 659369c42b
7 changed files with 208 additions and 12 deletions

View File

@@ -7,6 +7,7 @@ import (
"git.nwaifu.su/sergey/MyGoServer/cmd/apiserver/config"
"git.nwaifu.su/sergey/MyGoServer/internal/apiserver/logger"
"github.com/gorilla/mux"
)
type contextKey struct {
@@ -22,7 +23,7 @@ func saveConnInContext(ctx context.Context, c net.Conn) context.Context {
// Server represents the HTTP server
type Server struct {
config *config.Config
router *http.ServeMux
router *mux.Router
server *http.Server
}
@@ -36,7 +37,7 @@ func NewServer(cfg *config.Config) *Server {
logger.Initialize(cfg.Logging.Level, cfg.Logging.Format, cfg.Logging.Output)
// Create router
s.router = http.NewServeMux()
s.router = mux.NewRouter()
s.setupRoutes()
// Create HTTP server
@@ -55,7 +56,7 @@ func (s *Server) Start() error {
}
// GetRouter returns the HTTP router
func (s *Server) GetRouter() *http.ServeMux {
func (s *Server) GetRouter() *mux.Router {
return s.router
}