appview/state: add a permissive robots.txt #650

merged
opened by anirudh.fi targeting master from push-vyusnwqnmxwy

Maybe we load this from disk/elsewhere later?

Signed-off-by: Anirudh Oppiliappan anirudh@tangled.org

Changed files
+11
appview
+1
appview/state/router.go
··· 35 35 router.Get("/favicon.svg", s.Favicon) 36 36 router.Get("/favicon.ico", s.Favicon) 37 37 router.Get("/pwa-manifest.json", s.PWAManifest) 38 + router.Get("/robots.txt", s.RobotsTxt) 38 39 39 40 userRouter := s.UserRouter(&middleware) 40 41 standardRouter := s.StandardRouter(&middleware)
+10
appview/state/state.go
··· 203 203 s.pages.Favicon(w) 204 204 } 205 205 206 + func (s *State) RobotsTxt(w http.ResponseWriter, r *http.Request) { 207 + w.Header().Set("Content-Type", "text/plain") 208 + w.Header().Set("Cache-Control", "public, max-age=86400") // one day 209 + 210 + robotsTxt := `User-agent: * 211 + Allow: / 212 + ` 213 + w.Write([]byte(robotsTxt)) 214 + } 215 + 206 216 // https://developer.mozilla.org/en-US/docs/Web/Progressive_web_apps/Manifest 207 217 const manifestJson = `{ 208 218 "name": "tangled",