Added auth routes with jwt generation and middleware.
This commit is contained in:
+12
-2
@@ -18,11 +18,21 @@ func (s *Server) setupRoutes() *chi.Mux {
|
||||
|
||||
// Public routes
|
||||
router.Group(func(r chi.Router) {
|
||||
// Auth Routes
|
||||
router.Post("/register", s.handleRegister())
|
||||
router.Post("/login", s.handleLogin())
|
||||
router.Post("/logout", s.handleLogout())
|
||||
|
||||
// public pages
|
||||
r.Get("/", s.handleHome())
|
||||
})
|
||||
|
||||
//s.router.Get("/", s.handleIndex())
|
||||
//s.router.Post("/users", s.handleCreateUser())
|
||||
// User routes
|
||||
router.Group(func(r chi.Router) {
|
||||
// Requires log in
|
||||
r.Use(s.hasAuth)
|
||||
router.Mount("/users", s.userRoutes())
|
||||
})
|
||||
|
||||
return router
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user