basket-service/src/internal/app/server/router.go
Piotr Biernat afc18d34e1
Some checks failed
continuous-integration/drone/push Build is failing
vendor support and image build optimalization
2022-12-01 06:23:13 +01:00

31 lines
643 B
Go

package server
import (
"git.pbiernat.dev/egommerce/go-api-pkg/fluentd"
"github.com/gofiber/fiber/v2"
)
func SetupRoutes(s *Server) {
api := s.App.Group("/api")
v1 := api.Group("/v1")
v1.Post("/checkout", s.CheckoutHandler)
s.App.Get("/health", s.HealthHandler)
}
func SetupMiddlewares(s *Server) {
s.App.Use(LoggingMiddleware(s.log))
}
// Middlewares
func LoggingMiddleware(log *fluentd.Logger) func(c *fiber.Ctx) error {
return func(c *fiber.Ctx) error {
log.Log("Request: %s, remote: %s, via: %s",
c.Request().URI().String(),
c.Context().RemoteIP().String(),
string(c.Context().UserAgent()))
return c.Next()
}
}