mirror of
https://github.com/astaxie/beego.git
synced 2024-11-25 20:10:56 +00:00
code refactor
This commit is contained in:
parent
4995f91547
commit
9c17f73489
@ -82,19 +82,17 @@ func serverStaticRouter(ctx *context.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if strings.HasSuffix(requestPath, "/index.html") {
|
if strings.HasSuffix(requestPath, "/index.html") {
|
||||||
if utils.FileExists(filePath) {
|
fileReader, err := os.Open(filePath)
|
||||||
fileReader, err := os.Open(filePath)
|
if err != nil {
|
||||||
if err != nil {
|
if RunMode == "dev" {
|
||||||
if RunMode == "dev" {
|
Warn("Can't open the file:", filePath, err)
|
||||||
Warn("Can't open the file:", filePath, err)
|
|
||||||
}
|
|
||||||
http.NotFound(ctx.ResponseWriter, ctx.Request)
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
defer fileReader.Close()
|
http.NotFound(ctx.ResponseWriter, ctx.Request)
|
||||||
http.ServeContent(ctx.ResponseWriter, ctx.Request, filePath, fileInfo.ModTime(), fileReader)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
defer fileReader.Close()
|
||||||
|
http.ServeContent(ctx.ResponseWriter, ctx.Request, filePath, fileInfo.ModTime(), fileReader)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
isStaticFileToCompress := false
|
isStaticFileToCompress := false
|
||||||
|
Loading…
Reference in New Issue
Block a user