From e6d6419a6557385470ec6c9d9afc1cbe06f2b178 Mon Sep 17 00:00:00 2001 From: astaxie Date: Wed, 16 Jul 2014 22:27:53 +0800 Subject: [PATCH] beego: static file support robots.txt --- staticfile.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/staticfile.go b/staticfile.go index 52ab6dc4..7fa03b54 100644 --- a/staticfile.go +++ b/staticfile.go @@ -27,11 +27,14 @@ func serverStaticRouter(ctx *context.Context) { if len(prefix) == 0 { continue } - if requestPath == "/favicon.ico" { + if requestPath == "/favicon.ico" || requestPath == "/robots.txt" { file := path.Join(staticDir, requestPath) if utils.FileExists(file) { http.ServeFile(ctx.ResponseWriter, ctx.Request, file) return + } else { + http.NotFound(ctx.ResponseWriter, ctx.Request) + return } } if strings.HasPrefix(requestPath, prefix) {