forked from songquanpeng/go-file
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi-router.v1.go
37 lines (35 loc) · 1.22 KB
/
api-router.v1.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
package router
import (
"github.com/gin-gonic/gin"
"go-file/controller"
"go-file/middleware"
)
func setApiRouter(router *gin.Engine) {
router.Use(middleware.GlobalAPIRateLimit())
router.GET("/status", controller.GetStatus)
router.POST("/api/file", middleware.FileUploadPermissionCheck(), controller.UploadFile)
router.POST("/api/image", middleware.ImageUploadPermissionCheck(), controller.UploadImage)
router.GET("/api/notice", controller.GetNotice)
basicAuth := router.Group("/api")
basicAuth.Use(middleware.ApiAuth())
{
basicAuth.DELETE("/file", controller.DeleteFile)
basicAuth.DELETE("/image", controller.DeleteImage)
basicAuth.PUT("/user", middleware.NoTokenAuth(), controller.UpdateSelf)
basicAuth.POST("/token", controller.GenerateNewUserToken)
}
adminAuth := router.Group("/api")
adminAuth.Use(middleware.ApiAdminAuth())
{
adminAuth.POST("/user", controller.CreateUser)
adminAuth.PUT("/manage_user", controller.ManageUser)
adminAuth.GET("/option", controller.GetOptions)
adminAuth.PUT("/option", controller.UpdateOption)
statRouter := adminAuth.Group("/stat")
{
statRouter.GET("/ip", controller.GetIPs)
statRouter.GET("/url", controller.GetURLs)
statRouter.GET("/req", controller.GetReqs)
}
}
}