Files
trihuy-russian/web/controller/api.go
T

42 lines
860 B
Go
Raw Normal View History

2023-02-09 22:48:06 +03:30
package controller
2023-05-19 00:31:05 +03:30
import (
2025-09-19 10:05:43 +02:00
"github.com/mhsanaei/3x-ui/v2/web/service"
2023-05-19 00:31:05 +03:30
"github.com/gin-gonic/gin"
)
2023-02-09 22:48:06 +03:30
2023-04-02 02:30:15 +04:30
type APIController struct {
2023-04-09 23:13:18 +03:30
BaseController
inboundController *InboundController
2025-09-09 01:22:43 +02:00
serverController *ServerController
2023-05-19 00:31:05 +03:30
Tgbot service.Tgbot
2023-02-09 22:48:06 +03:30
}
func NewAPIController(g *gin.RouterGroup) *APIController {
2023-04-09 23:13:18 +03:30
a := &APIController{}
a.initRouter(g)
return a
2023-02-09 22:48:06 +03:30
}
func (a *APIController) initRouter(g *gin.RouterGroup) {
2025-09-09 01:22:43 +02: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 18:46:09 +03:30
}
2023-05-19 00:31:05 +03:30
2025-09-09 01:22:43 +02:00
func (a *APIController) BackuptoTgbot(c *gin.Context) {
2023-05-21 03:29:27 +04:30
a.Tgbot.SendBackupToAdmins()
2023-05-19 00:31:05 +03:30
}