mirror of
https://github.com/astaxie/beego.git
synced 2024-11-01 02:30:55 +00:00
beego: static file support robots.txt
This commit is contained in:
parent
6357c88d97
commit
e6d6419a65
@ -27,11 +27,14 @@ func serverStaticRouter(ctx *context.Context) {
|
|||||||
if len(prefix) == 0 {
|
if len(prefix) == 0 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if requestPath == "/favicon.ico" {
|
if requestPath == "/favicon.ico" || requestPath == "/robots.txt" {
|
||||||
file := path.Join(staticDir, requestPath)
|
file := path.Join(staticDir, requestPath)
|
||||||
if utils.FileExists(file) {
|
if utils.FileExists(file) {
|
||||||
http.ServeFile(ctx.ResponseWriter, ctx.Request, file)
|
http.ServeFile(ctx.ResponseWriter, ctx.Request, file)
|
||||||
return
|
return
|
||||||
|
} else {
|
||||||
|
http.NotFound(ctx.ResponseWriter, ctx.Request)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if strings.HasPrefix(requestPath, prefix) {
|
if strings.HasPrefix(requestPath, prefix) {
|
||||||
|
Loading…
Reference in New Issue
Block a user