go-jwtserver/internal/router/router.go

30 lines
595 B
Go

package router
import (
"time"
"forges.cadoles.com/mlamalle/go-jwtserver/internal/jwtcontroller"
"github.com/go-chi/chi"
"github.com/go-chi/chi/middleware"
)
func InitializeRouter() chi.Router {
r := chi.NewRouter()
// Define base middlewares
r.Use(middleware.RequestID)
r.Use(middleware.Logger)
r.Use(middleware.Recoverer)
r.Use(middleware.URLFormat)
r.Use(middleware.Timeout(60 * time.Second))
r.Route("/api/", func(r chi.Router) {
// Middleware routes
r.Post("/user/new", jwtcontroller.CreateAccount)
r.Post("/user/login", jwtcontroller.Authenticate)
})
return r
}