This commit is contained in:
2024-08-02 14:19:57 +08:00
parent c178e1672b
commit 527c7aa372
18 changed files with 904 additions and 0 deletions

43
core/gin_handler.go Normal file
View File

@@ -0,0 +1,43 @@
package core
import (
"fmt"
"github.com/gin-gonic/gin"
)
func HandlerIpv6M3u(c *gin.Context) {
filename := "./ipv6.m3u"
// 检查缓存文件是否存在
if exists := IsFileExist(filename); !exists {
c.JSON(200, gin.H{"code": -1, "msg": "缓存文件不存在"})
return
}
content, err := ReadFile(filename)
if err != nil {
fmt.Printf("读取缓存文件ipv6.m3u失败%s\n", err.Error())
c.JSON(200, gin.H{"code": -1, "msg": "读取缓存文件失败"})
return
}
// 返回响应内容
c.Header("Content-Type", "text/plain; charset=utf-8")
c.String(200, content)
}
func HandlerDiypIpv6IptvM3u(c *gin.Context) {
filename := "./ipv6-txt.m3u"
// 检查缓存文件是否存在
if exists := IsFileExist(filename); !exists {
c.JSON(200, gin.H{"code": -1, "msg": "缓存文件不存在"})
return
}
content, err := ReadFile(filename)
if err != nil {
fmt.Printf("读取缓存文件ipv6-txt.m3u失败%s\n", err.Error())
c.JSON(200, gin.H{"code": -1, "msg": "读取缓存文件失败"})
return
}
// 返回响应内容
c.Header("Content-Type", "text/plain; charset=utf-8")
c.String(200, content)
}