-
Notifications
You must be signed in to change notification settings - Fork 0
/
router.go
57 lines (50 loc) · 1.71 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package main
import (
"github.com/gin-gonic/gin"
)
/* API 세팅 */
func SetupRouter() *gin.Engine {
r := gin.Default()
loginFunc := Login()
callbackFunc := LoginCallback()
// callback by oauth CA
r.GET("/auth/callback/google", callbackFunc)
r.GET("/auth/callback/facebook", callbackFunc)
r.GET("/auth/callback/github", callbackFunc)
r.POST("/init", InitTable)
r.DELETE("/delete", DeleteTable)
r.GET("/login/:CA", loginFunc)
// To run in Postman
api := r.Group("/api")
{
// Use를 통해 Middleware인 AuthorizeAccount를 가져와 MiddleWare에서 검증 진행
department := api.Group("/department").Use(AuthorizeAccount())
{
department.GET("/only", ReadDepartmentOnly)
department.GET("/", ReadDepartment)
department.GET("/:name", SearchDepartmentByName)
department.GET("/:name/employee", ReadEmployeeInDepartment) // 부서에 속한 직원 명단 가져오기
department.PUT("/", UpdateDepartment)
department.POST("/", AddDepartment)
department.DELETE("/:name", DeleteDepartment)
}
employee := api.Group("/employee").Use(AuthorizeAccount())
{
employee.GET("/", ReadEmployee)
employee.GET("/name/:name", SearchEmployeeByName)
employee.GET("/day/:days", SearchEmployeeByDay)
employee.PUT("/:id", UpdateEmployee)
employee.POST("/", AddEmployee)
employee.DELETE("/:name", DeleteEmployee)
employee.DELETE("/id/:id", DeleteEmployeById)
}
assign := api.Group("/assign").Use(AuthorizeAccount())
{
assign.POST("/:name/:department", AddEmployeeDepartment)
assign.POST("/id/:eid/:department", AddEmployeeDepartmentById)
assign.DELETE("/:name/:department", DeleteEmployeeDepartment)
assign.DELETE("/id/:eid/:department", DeleteEmployeeDepartmentById)
}
}
return r
}