beego: static file support robots.txt
Showing
1 changed file
with
4 additions
and
1 deletions
| ... | @@ -27,11 +27,14 @@ func serverStaticRouter(ctx *context.Context) { | ... | @@ -27,11 +27,14 @@ func serverStaticRouter(ctx *context.Context) { |
| 27 | if len(prefix) == 0 { | 27 | if len(prefix) == 0 { |
| 28 | continue | 28 | continue |
| 29 | } | 29 | } |
| 30 | if requestPath == "/favicon.ico" { | 30 | if requestPath == "/favicon.ico" || requestPath == "/robots.txt" { |
| 31 | file := path.Join(staticDir, requestPath) | 31 | file := path.Join(staticDir, requestPath) |
| 32 | if utils.FileExists(file) { | 32 | if utils.FileExists(file) { |
| 33 | http.ServeFile(ctx.ResponseWriter, ctx.Request, file) | 33 | http.ServeFile(ctx.ResponseWriter, ctx.Request, file) |
| 34 | return | 34 | return |
| 35 | } else { | ||
| 36 | http.NotFound(ctx.ResponseWriter, ctx.Request) | ||
| 37 | return | ||
| 35 | } | 38 | } |
| 36 | } | 39 | } |
| 37 | if strings.HasPrefix(requestPath, prefix) { | 40 | if strings.HasPrefix(requestPath, prefix) { | ... | ... |
-
Please register or sign in to post a comment