-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathroutes.go
47 lines (36 loc) · 1.63 KB
/
routes.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package main
import (
"net/http"
"github.com/go-chi/chi/v5"
)
func (app *application) routes() *chi.Mux {
// Add your middleware here
app.App.Routes.Use(app.Middleware.CheckRememberMe)
// Add your routes here
app.App.Routes.Get("/", app.Handlers.Home)
app.App.Routes.Get("/go-page", app.Handlers.GoPage)
app.App.Routes.Get("/jet-page", app.Handlers.JetPage)
app.App.Routes.Get("/sessions", app.Handlers.SessionTest)
app.App.Routes.Get("/json", app.Handlers.JSON)
app.App.Routes.Get("/xml", app.Handlers.XML)
app.App.Routes.Get("/download-file", app.Handlers.DownloadFile)
app.App.Routes.Get("/crypto", app.Handlers.TestCrypto)
app.App.Routes.Get("/cache-test", app.Handlers.ShowCachePage)
// Auth routes
app.App.Routes.Get("/users/#", app.Handlers.UserLogin)
app.App.Routes.Post("/users/#", app.Handlers.PostUserLogin)
app.App.Routes.Get("/users/#", app.Handlers.PostUser#)
app.App.Routes.Post("/users/#", app.Handlers.PostUser#)
app.App.Routes.Get("/users/logout", app.Handlers.Logout)
app.App.Routes.Get("/users/profile", app.Handlers.CurrentUserProfile)
app.App.Routes.Get("/users/forgot-password", app.Handlers.ForgotPassword)
app.App.Routes.Post("/users/forgot-password", app.Handlers.PostForgotPassword)
app.App.Routes.Get("/users/reset-password", app.Handlers.ResetPasswordForm)
app.App.Routes.Post("/users/reset-password", app.Handlers.PostResetPassword)
// API routes
app.App.Routes.Mount("/api", app.ApiRoutes())
// Static file server
fileServer := http.FileServer(http.Dir("./public"))
app.App.Routes.Handle("/public/*", http.StripPrefix("/public", fileServer))
return app.App.Routes
}