summaryrefslogtreecommitdiff
path: root/internal/api/robots
diff options
context:
space:
mode:
Diffstat (limited to 'internal/api/robots')
-rw-r--r--internal/api/robots/robots.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/internal/api/robots/robots.go b/internal/api/robots/robots.go
index 98db4682d..b72a01ed6 100644
--- a/internal/api/robots/robots.go
+++ b/internal/api/robots/robots.go
@@ -49,9 +49,29 @@ func (m *Module) Route(attachHandler func(method string, path string, f ...gin.H
}
func (m *Module) robotsGETHandler(c *gin.Context) {
+ const ETag = "\"" + apiutil.RobotsTxtETag + "\""
+ c.Header("ETag", ETag)
+
+ if c.Request.Header.Get("If-None-Match") == ETag {
+ // Cached.
+ c.AbortWithStatus(http.StatusNotModified)
+ return
+ }
+
+ // Not cached, serve.
c.String(http.StatusOK, apiutil.RobotsTxt)
}
func (m *Module) robotsGETHandlerDisallowNodeInfo(c *gin.Context) {
+ const ETag = "\"" + apiutil.RobotsTxtDisallowNodeInfoETag + "\""
+ c.Header("ETag", ETag)
+
+ if c.Request.Header.Get("If-None-Match") == ETag {
+ // Cached.
+ c.AbortWithStatus(http.StatusNotModified)
+ return
+ }
+
+ // Not cached, serve.
c.String(http.StatusOK, apiutil.RobotsTxtDisallowNodeInfo)
}