router.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package system
  2. import (
  3. "github.com/0xJacky/Nginx-UI/internal/middleware"
  4. "github.com/gin-gonic/gin"
  5. )
  6. func authIfInstalled(ctx *gin.Context) {
  7. if installLockStatus() || isInstallTimeoutExceeded() {
  8. middleware.AuthRequired()(ctx)
  9. } else {
  10. ctx.Next()
  11. }
  12. }
  13. func InitPublicRouter(r *gin.RouterGroup) {
  14. r.GET("install", InstallLockCheck)
  15. r.POST("install", middleware.EncryptedParams(), InstallNginxUI)
  16. r.GET("translation/:code", GetTranslation)
  17. }
  18. func InitPrivateRouter(r *gin.RouterGroup) {
  19. r.GET("upgrade/release", GetRelease)
  20. r.GET("upgrade/current", GetCurrentVersion)
  21. r.GET("system/backup", CreateBackup)
  22. }
  23. func InitSelfCheckRouter(r *gin.RouterGroup) {
  24. r.GET("self_check", authIfInstalled, SelfCheck)
  25. r.POST("self_check/:name/fix", authIfInstalled, SelfCheckFix)
  26. }
  27. func InitBackupRestoreRouter(r *gin.RouterGroup) {
  28. r.POST("system/backup/restore",
  29. authIfInstalled,
  30. middleware.EncryptedForm(),
  31. RestoreBackup)
  32. }
  33. func InitWebSocketRouter(r *gin.RouterGroup) {
  34. r.GET("upgrade/perform", PerformCoreUpgrade)
  35. r.GET("self_check/websocket", CheckWebSocket)
  36. }