beego: static file support robots.txt

This commit is contained in:
astaxie 2014-07-16 22:27:53 +08:00
parent 6357c88d97
commit e6d6419a65
1 changed files with 4 additions and 1 deletions

View File

@ -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) {