Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/MHSanaei/3x-ui.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSanaei <ho3ein.sanaei@gmail.com>2025-09-09 02:22:43 +0300
committermhsanaei <ho3ein.sanaei@gmail.com>2025-09-09 03:32:05 +0300
commitfe9f0d1d0e86f55a97e3905358888f595b9bd08b (patch)
tree2210606a64b38e89edf4197268957913efbb7f06 /web/controller/api.go
parent18d74d54caa5f55b8d9048b49ad28b42be31b322 (diff)
api (#3434)
Diffstat (limited to 'web/controller/api.go')
-rw-r--r--web/controller/api.go52
1 files changed, 16 insertions, 36 deletions
diff --git a/web/controller/api.go b/web/controller/api.go
index 32af934e..6edd7939 100644
--- a/web/controller/api.go
+++ b/web/controller/api.go
@@ -9,6 +9,7 @@ import (
type APIController struct {
BaseController
inboundController *InboundController
+ serverController *ServerController
Tgbot service.Tgbot
}
@@ -19,43 +20,22 @@ func NewAPIController(g *gin.RouterGroup) *APIController {
}
func (a *APIController) initRouter(g *gin.RouterGroup) {
- g = g.Group("/panel/api/inbounds")
- g.Use(a.checkLogin)
-
- a.inboundController = NewInboundController(g)
-
- inboundRoutes := []struct {
- Method string
- Path string
- Handler gin.HandlerFunc
- }{
- {"GET", "/createbackup", a.createBackup},
- {"GET", "/list", a.inboundController.getInbounds},
- {"GET", "/get/:id", a.inboundController.getInbound},
- {"GET", "/getClientTraffics/:email", a.inboundController.getClientTraffics},
- {"GET", "/getClientTrafficsById/:id", a.inboundController.getClientTrafficsById},
- {"POST", "/add", a.inboundController.addInbound},
- {"POST", "/del/:id", a.inboundController.delInbound},
- {"POST", "/update/:id", a.inboundController.updateInbound},
- {"POST", "/clientIps/:email", a.inboundController.getClientIps},
- {"POST", "/clearClientIps/:email", a.inboundController.clearClientIps},
- {"POST", "/addClient", a.inboundController.addInboundClient},
- {"POST", "/:id/delClient/:clientId", a.inboundController.delInboundClient},
- {"POST", "/updateClient/:clientId", a.inboundController.updateInboundClient},
- {"POST", "/:id/resetClientTraffic/:email", a.inboundController.resetClientTraffic},
- {"POST", "/resetAllTraffics", a.inboundController.resetAllTraffics},
- {"POST", "/resetAllClientTraffics/:id", a.inboundController.resetAllClientTraffics},
- {"POST", "/delDepletedClients/:id", a.inboundController.delDepletedClients},
- {"POST", "/onlines", a.inboundController.onlines},
- {"POST", "/lastOnline", a.inboundController.lastOnline},
- {"POST", "/updateClientTraffic/:email", a.inboundController.updateClientTraffic},
- }
-
- for _, route := range inboundRoutes {
- g.Handle(route.Method, route.Path, route.Handler)
- }
+ // 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) createBackup(c *gin.Context) {
+func (a *APIController) BackuptoTgbot(c *gin.Context) {
a.Tgbot.SendBackupToAdmins()
}