From c7906e85980c45fd3f37d11b80e14a1075d94d4f Mon Sep 17 00:00:00 2001 From: mhsanaei Date: Tue, 23 Jul 2024 11:28:28 +0200 Subject: API - Get client's traffic By ID Co-Authored-By: Hassan Ali Gilani --- web/controller/api.go | 1 + web/controller/inbound.go | 10 ++++++++++ 2 files changed, 11 insertions(+) (limited to 'web/controller') diff --git a/web/controller/api.go b/web/controller/api.go index 6281097b..9944e2a3 100644 --- a/web/controller/api.go +++ b/web/controller/api.go @@ -33,6 +33,7 @@ func (a *APIController) initRouter(g *gin.RouterGroup) { {"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}, diff --git a/web/controller/inbound.go b/web/controller/inbound.go index cc34d1d8..c22ce192 100644 --- a/web/controller/inbound.go +++ b/web/controller/inbound.go @@ -77,6 +77,16 @@ func (a *InboundController) getClientTraffics(c *gin.Context) { jsonObj(c, clientTraffics, nil) } +func (a *InboundController) getClientTrafficsById(c *gin.Context) { + id := c.Param("id") + clientTraffics, err := a.inboundService.GetClientTrafficByID(id) + if err != nil { + jsonMsg(c, "Error getting traffics", err) + return + } + jsonObj(c, clientTraffics, nil) +} + func (a *InboundController) addInbound(c *gin.Context) { inbound := &model.Inbound{} err := c.ShouldBind(inbound) -- cgit v1.2.3