mirror of
https://github.com/nitezs/sub2clash.git
synced 2024-12-23 21:24:42 -05:00
8d06ab3175
fix: 修复当订阅链接有多个 clash 配置时丢失节点的问题 update: 增加检测更新 modify: 修改数据库路径 modify: 修改短链生成逻辑 modify: 统一输出信息
49 lines
850 B
Go
49 lines
850 B
Go
package api
|
|
|
|
import (
|
|
"embed"
|
|
"github.com/gin-gonic/gin"
|
|
"html/template"
|
|
"sub2clash/api/controller"
|
|
"sub2clash/config"
|
|
"sub2clash/middleware"
|
|
)
|
|
|
|
//go:embed templates/*
|
|
var templates embed.FS
|
|
|
|
func SetRoute(r *gin.Engine) {
|
|
r.Use(middleware.ZapLogger())
|
|
// 使用内嵌的模板文件
|
|
r.SetHTMLTemplate(template.Must(template.New("").ParseFS(templates, "templates/*")))
|
|
r.GET(
|
|
"/", func(c *gin.Context) {
|
|
c.HTML(
|
|
200, "index.html", gin.H{
|
|
"Version": config.Version,
|
|
},
|
|
)
|
|
},
|
|
)
|
|
r.GET(
|
|
"/clash", func(c *gin.Context) {
|
|
controller.SubmodHandler(c)
|
|
},
|
|
)
|
|
r.GET(
|
|
"/meta", func(c *gin.Context) {
|
|
controller.SubHandler(c)
|
|
},
|
|
)
|
|
r.POST(
|
|
"/short", func(c *gin.Context) {
|
|
controller.ShortLinkGenHandler(c)
|
|
},
|
|
)
|
|
r.GET(
|
|
"/s/:hash", func(c *gin.Context) {
|
|
controller.ShortLinkGetHandler(c)
|
|
},
|
|
)
|
|
}
|