api.go 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package controller
  2. import (
  3. "github.com/gin-gonic/gin"
  4. )
  5. type APIController struct {
  6. BaseController
  7. inboundController *InboundController
  8. settingController *SettingController
  9. }
  10. func NewAPIController(g *gin.RouterGroup) *APIController {
  11. a := &APIController{}
  12. a.initRouter(g)
  13. return a
  14. }
  15. func (a *APIController) initRouter(g *gin.RouterGroup) {
  16. g = g.Group("/xui/API/inbounds")
  17. g.Use(a.checkLogin)
  18. g.GET("/", a.inbounds)
  19. g.GET("/get/:id", a.inbound)
  20. g.POST("/add", a.addInbound)
  21. g.POST("/del/:id", a.delInbound)
  22. g.POST("/update/:id", a.updateInbound)
  23. a.inboundController = NewInboundController(g)
  24. }
  25. func (a *APIController) inbounds(c *gin.Context) {
  26. a.inboundController.getInbounds(c)
  27. }
  28. func (a *APIController) inbound(c *gin.Context) {
  29. a.inboundController.getInbound(c)
  30. }
  31. func (a *APIController) addInbound(c *gin.Context) {
  32. a.inboundController.addInbound(c)
  33. }
  34. func (a *APIController) delInbound(c *gin.Context) {
  35. a.inboundController.delInbound(c)
  36. }
  37. func (a *APIController) updateInbound(c *gin.Context) {
  38. a.inboundController.updateInbound(c)
  39. }