2023-02-09 19:18:06 +00:00
|
|
|
package controller
|
|
|
|
|
2023-05-18 21:01:05 +00:00
|
|
|
import (
|
|
|
|
"x-ui/web/service"
|
|
|
|
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
)
|
2023-02-09 19:18:06 +00:00
|
|
|
|
2023-04-01 22:00:15 +00:00
|
|
|
type APIController struct {
|
2023-04-09 19:43:18 +00:00
|
|
|
BaseController
|
|
|
|
inboundController *InboundController
|
2025-09-08 23:22:43 +00:00
|
|
|
serverController *ServerController
|
2023-05-18 21:01:05 +00:00
|
|
|
Tgbot service.Tgbot
|
2023-02-09 19:18:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func NewAPIController(g *gin.RouterGroup) *APIController {
|
2023-04-09 19:43:18 +00:00
|
|
|
a := &APIController{}
|
|
|
|
a.initRouter(g)
|
|
|
|
return a
|
2023-02-09 19:18:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (a *APIController) initRouter(g *gin.RouterGroup) {
|
2025-09-08 23:22:43 +00:00
|
|
|
// Main API group
|
|
|
|
api := g.Group("/panel/api")
|
|
|
|
api.Use(a.checkLogin)
|
|
|
|
|
|
|
|
// Inbounds API
|
|
|
|
inbounds := api.Group("/inbounds")
|
|
|
|
a.inboundController = NewInboundController(inbounds)
|
|
|
|
|
|
|
|
// Server API
|
|
|
|
server := api.Group("/server")
|
|
|
|
a.serverController = NewServerController(server)
|
|
|
|
|
|
|
|
// Extra routes
|
|
|
|
api.GET("/backuptotgbot", a.BackuptoTgbot)
|
2023-04-25 15:16:09 +00:00
|
|
|
}
|
2023-05-18 21:01:05 +00:00
|
|
|
|
2025-09-08 23:22:43 +00:00
|
|
|
func (a *APIController) BackuptoTgbot(c *gin.Context) {
|
2023-05-20 22:59:27 +00:00
|
|
|
a.Tgbot.SendBackupToAdmins()
|
2023-05-18 21:01:05 +00:00
|
|
|
}
|