-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrouter.go
42 lines (35 loc) · 1.2 KB
/
router.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
package main
import (
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
"github.com/hiyali/katip-be/config"
"github.com/hiyali/katip-be/handlers"
)
func routerRegister(e *echo.Echo) {
// JWT config
jwtConfig := config.GetJwtConfig()
// Ping
e.GET("/api/ping", handlers.Ping)
// Auth
e.POST("/api/auth/login", handlers.AuthLogin)
// User Register
e.POST("/api/register", handlers.UserRegister)
e.GET("/api/register-confirm", handlers.UserRegisterConfirm)
e.POST("/api/forget-password", handlers.UserForgetPassword)
e.POST("/api/reset-password", handlers.UserResetPassword)
// User Group (need login)
ug := e.Group("/api/user")
ug.Use(middleware.JWTWithConfig(jwtConfig))
ug.GET("", handlers.UserGetInfo)
ug.PUT("", handlers.UserUpdateInfo)
ug.PUT("/change-password", handlers.UserChangePassword)
// ug.POST("/logout", handlers.UserLogout) // server side logout
// Record Group (need login)
rg := e.Group("/api/record")
rg.Use(middleware.JWTWithConfig(jwtConfig))
rg.GET("", handlers.RecordGetAllPageable)
rg.POST("", handlers.RecordCreateOne)
rg.GET("/:id", handlers.RecordGetOne)
rg.PUT("/:id", handlers.RecordUpdateOne)
rg.DELETE("/:id", handlers.RecordDeleteOne)
}