feat(sub): add HEAD method support for sub resource

- Implement HEAD method for retrieving sub resource metadata for some clients (example: Karing)
This commit is contained in:
Anem
2025-12-05 21:38:30 +08:00
parent 65e51f8aea
commit fc88f5a509
+7
View File
@@ -21,6 +21,7 @@ func NewSubHandler(g *gin.RouterGroup) {
func (s *SubHandler) initRouter(g *gin.RouterGroup) {
g.GET("/:subid", s.subs)
g.HEAD("/:subid", s.subs)
}
func (s *SubHandler) subs(c *gin.Context) {
@@ -54,5 +55,11 @@ func (s *SubHandler) subs(c *gin.Context) {
c.Writer.Header().Set("Profile-Update-Interval", headers[1])
c.Writer.Header().Set("Profile-Title", headers[2])
// For HEAD requests
if c.Request.Method == "HEAD" {
c.Status(200)
return
}
c.String(200, *result)
}