1234567891011121314151617181920212223242526272829303132333435363738394041 |
- package controller
- import (
- "x-ui/web/service"
- "github.com/gin-gonic/gin"
- )
- type APIController struct {
- BaseController
- inboundController *InboundController
- serverController *ServerController
- Tgbot service.Tgbot
- }
- func NewAPIController(g *gin.RouterGroup) *APIController {
- a := &APIController{}
- a.initRouter(g)
- return a
- }
- func (a *APIController) initRouter(g *gin.RouterGroup) {
- // 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)
- }
- func (a *APIController) BackuptoTgbot(c *gin.Context) {
- a.Tgbot.SendBackupToAdmins()
- }
|