summaryrefslogtreecommitdiff
path: root/internal
diff options
from:
to:
context:
space:
mode:
authorGravatar SayaAndy <saya.andy@posteo.com> 2026-03-30 23:33:53 +0700
committerGravatar SayaAndy <saya.andy@posteo.com> 2026-03-30 23:33:53 +0700
commitbe906e1cc4ec3e92bcb14ee08256b53f3a4b44e2 (patch)
tree3dc1411141509f34e2468946145a646c845d001e /internal
parent7a40c01dd14f04787f5052d0c89e0d6fb9ce597f (diff)
downloadweb-be906e1cc4ec3e92bcb14ee08256b53f3a4b44e2.tar.gz
web-be906e1cc4ec3e92bcb14ee08256b53f3a4b44e2.zip
feat: generate robots.txt
Diffstat (limited to 'internal')
-rw-r--r--internal/router/handlers/robots.txt.go48
1 files changed, 48 insertions, 0 deletions
diff --git a/internal/router/handlers/robots.txt.go b/internal/router/handlers/robots.txt.go
new file mode 100644
index 0000000..fc60af4
--- /dev/null
+++ b/internal/router/handlers/robots.txt.go
@@ -0,0 +1,48 @@
+package handlers
+
+import (
+ "time"
+
+ "github.com/SayaAndy/saya-today-web/internal/router"
+ "github.com/gofiber/fiber/v2"
+)
+
+type RobotsTxtHandler struct {
+ router.BasicHandler
+}
+
+func init() {
+ router.Routes = append(router.Routes, &RobotsTxtHandler{})
+}
+
+func (r *RobotsTxtHandler) Filter() (method string, path string) {
+ return "GET", "/robots.txt"
+}
+
+func (r *RobotsTxtHandler) IsTemplated() bool {
+ return false
+}
+
+func (r *RobotsTxtHandler) TemplatesToInject() []string {
+ return []string{"views/pages/robots.txt"}
+}
+
+func (r *RobotsTxtHandler) ToCache() router.CacheSetting {
+ return router.ByUrlOnly
+}
+
+func (r *RobotsTxtHandler) CacheDuration() time.Duration {
+ return time.Hour
+}
+
+func (r *RobotsTxtHandler) ToValidateLang() router.LangSetting {
+ return router.NotRequired
+}
+
+func (r *RobotsTxtHandler) ContentType() string {
+ return fiber.MIMETextPlainCharsetUTF8
+}
+
+func (r *RobotsTxtHandler) Render(c *fiber.Ctx, supplements *router.Supplements, lang string, templateMap fiber.Map) (statusCode int, err error) {
+ return fiber.StatusOK, nil
+}