feat: token based authentication, authenticate route, token storage

This commit is contained in:
2026-04-10 14:01:03 +02:00
parent a7cdb9efb1
commit b2244fef58
10 changed files with 251 additions and 7 deletions
+3 -1
View File
@@ -25,6 +25,8 @@ func (app *application) routes() http.Handler {
router.HandlerFunc(http.MethodDelete, "/v1/movies/:id", app.deleteMovieHandler)
router.HandlerFunc(http.MethodPost, "/v1/users", app.registerUserHandler)
router.HandlerFunc(http.MethodPut, "/v1/users/activated", app.activateUserHandler)
router.HandlerFunc(http.MethodPost, "/v1/tokens/authentication", app.createAuthenticationTokenHandler)
// Wrap the router with the rateLimit() middleware.
return app.recoverPanic(app.rateLimit(router))
// Use the authenticate() middleware on all requests.
return app.recoverPanic(app.rateLimit(app.authenticate(router)))
}