first commit

This commit is contained in:
2024-04-08 17:17:57 +00:00
commit 3e3b9a8c61
9 changed files with 296 additions and 0 deletions

35
cmd/server/api/api.go Normal file
View File

@@ -0,0 +1,35 @@
package api
import (
"fmt"
"net/http"
"github.com/go-chi/chi/v5"
"github.com/go-chi/chi/v5/middleware"
)
type (
Server struct {
handler http.Handler
services *Services
}
Services struct {
}
)
func New(services *Services) *Server {
r := chi.NewRouter()
r.Use(middleware.RequestID)
r.Use(middleware.Logger)
r.Use(middleware.Recoverer)
return &Server{
handler: r,
services: services,
}
}
func (s *Server) ListenAndServe(port uint16) error {
return http.ListenAndServe(fmt.Sprintf(":%d", port), s.handler)
}