identity-service/internal/app/router.go

27 lines
726 B
Go
Raw Normal View History

2022-06-19 15:19:05 +02:00
package app
import (
"net/http"
"git.pbiernat.dev/egommerce/application/services/identity/internal/app/handler"
"github.com/gorilla/mux"
)
func SetupRouter(env *handler.Env) *mux.Router {
r := mux.NewRouter()
r.NotFoundHandler = &handler.NotFoundHandler{}
r.MethodNotAllowedHandler = &handler.MethodNotAllowedHandler{}
r.Use(PrepareHeadersMiddleware)
r.Use(ValidateJsonBodyMiddleware) // probably not needed
r.Use(LoggingMiddleware)
hc := r.PathPrefix("/health").Subrouter()
hc.Handle("", handler.Init(env, handler.HealthCheckHandler)).Methods(http.MethodGet)
auth := r.PathPrefix("/auth").Subrouter()
auth.Handle("/login", handler.Init(env, handler.AuthLoginHandler)).Methods(http.MethodPost)
return r
}