go-jwtserver/internal/router/router.go

30 lines
596 B
Go
Raw Normal View History

2020-07-16 10:51:50 +02:00
package router
import (
"time"
2020-07-16 14:04:51 +02:00
jwtmiddleware "forge.cadoles.com/mlamalle/go-jwtserver/middleware"
2020-07-16 10:51:50 +02:00
"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
2020-07-16 14:04:51 +02:00
r.Post("/user/new", jwtmiddleware.CreateAccount)
r.Post("/user/login", jwtmiddleware.Authenticate)
2020-07-16 10:51:50 +02:00
})
return r
}