go-jwtserver/internal/router/router.go

30 lines
594 B
Go
Raw Normal View History

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