Initial commit

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
谢宇宁
2026-10-22 14:47:17 +07:00
co-authored by Claude Opus 5.5
commit 3639d2184a
574 changed files with 61690 additions and 0 deletions
+38
View File
@@ -0,0 +1,38 @@
package web
import (
"net/http"
"strings"
"videoweb/app/service/configser"
"videoweb/app/service/seoser"
"github.com/gin-gonic/gin"
)
// RobotsTXT 动态 robots.txt(含 Sitemap 声明)。
func RobotsTXT(c *gin.Context) {
cfg := configser.FetchAppConfigVMOrEmpty(c)
foreverURL := seoser.ResolveSiteURL(c, cfg)
c.Header("Content-Type", "text/plain; charset=utf-8")
c.Header("Cache-Control", "public, max-age=3600")
c.String(http.StatusOK, seoser.BuildRobotsTXT(foreverURL))
}
// SEOVerifyFile 提供百度 HTML 验证文件和 IndexNow key.txt。
func SEOVerifyFile(c *gin.Context) {
codes := seoser.VerifyFromConfig()
name := strings.TrimPrefix(c.Request.URL.Path, "/")
switch {
case codes.BaiduHTML != "" && name == codes.BaiduHTML:
c.Header("Cache-Control", "public, max-age=86400")
c.String(http.StatusOK, codes.Baidu)
return
case codes.IndexNowKey != "" && name == codes.IndexNowKey+".txt":
c.Header("Cache-Control", "public, max-age=86400")
c.Data(http.StatusOK, "text/plain; charset=utf-8", []byte(codes.IndexNowKey))
return
}
c.Status(http.StatusNotFound)
}