forked from hossinasaadi/x-ui
-
-
Notifications
You must be signed in to change notification settings - Fork 508
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Alireza Ahmadi
committed
Mar 28, 2023
1 parent
1780f06
commit f3df93a
Showing
4 changed files
with
554 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package controller | ||
|
||
import ( | ||
"encoding/base64" | ||
"x-ui/web/service" | ||
|
||
"github.com/gin-gonic/gin" | ||
) | ||
|
||
type SUBController struct { | ||
BaseController | ||
|
||
subService service.SubService | ||
} | ||
|
||
func NewSUBController(g *gin.RouterGroup) *SUBController { | ||
a := &SUBController{} | ||
a.initRouter(g) | ||
return a | ||
} | ||
|
||
func (a *SUBController) initRouter(g *gin.RouterGroup) { | ||
g = g.Group("/sub") | ||
|
||
g.GET("/:subid", a.subs) | ||
} | ||
|
||
func (a *SUBController) subs(c *gin.Context) { | ||
subId := c.Param("subid") | ||
host := c.Request.Host | ||
subs, err := a.subService.GetSubs(subId, host) | ||
if err != nil { | ||
c.String(400, "Error!") | ||
} else { | ||
result := "" | ||
for _, sub := range subs { | ||
result += sub + "\n" | ||
} | ||
c.String(200, base64.StdEncoding.EncodeToString([]byte(result))) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.