base_router.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. package routers
  2. import (
  3. "github.com/allanpk716/ChineseSubFinder/internal/backend/controllers/base"
  4. v1 "github.com/allanpk716/ChineseSubFinder/internal/backend/controllers/v1"
  5. "github.com/allanpk716/ChineseSubFinder/internal/backend/middle"
  6. "github.com/gin-gonic/gin"
  7. )
  8. func InitRouter(router *gin.Engine) {
  9. cbBase := base.NewControllerBase()
  10. cbV1 := v1.NewControllerBase()
  11. // 基础的路由
  12. router.GET("/system-status", cbBase.SystemStatusHandler)
  13. router.POST("/setup", cbBase.SetupHandler)
  14. router.POST("/login", cbBase.LoginHandler)
  15. router.POST("/logout", middle.CheckAuth(), cbBase.LogoutHandler)
  16. router.POST("/change-pwd", middle.CheckAuth(), cbBase.ChangePwdHandler)
  17. // v1路由: /v1/xxx
  18. GroupV1 := router.Group("/" + cbV1.GetVersion())
  19. {
  20. GroupV1.Use(middle.CheckAuth())
  21. GroupV1.GET("/settings", cbV1.SettingsHandler)
  22. GroupV1.PATCH("/settings", cbV1.SettingsHandler)
  23. GroupV1.POST("/check-proxy", cbV1.CheckProxyHandler)
  24. GroupV1.POST("/check-path", cbV1.CheckPathHandler)
  25. GroupV1.POST("/jobs/start", cbV1.JobStartHandler)
  26. GroupV1.POST("/jobs/stop", cbV1.JobStopHandler)
  27. }
  28. }