mirror of
https://github.com/astaxie/beego.git
synced 2024-11-22 11:40:55 +00:00
fix static file route
This commit is contained in:
parent
a8c2deb014
commit
769f7c751b
@ -546,6 +546,9 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request)
|
|||||||
|
|
||||||
//static file server
|
//static file server
|
||||||
for prefix, staticDir := range StaticDir {
|
for prefix, staticDir := range StaticDir {
|
||||||
|
if len(prefix) == 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
if r.URL.Path == "/favicon.ico" {
|
if r.URL.Path == "/favicon.ico" {
|
||||||
file := path.Join(staticDir, r.URL.Path)
|
file := path.Join(staticDir, r.URL.Path)
|
||||||
if utils.FileExists(file) {
|
if utils.FileExists(file) {
|
||||||
@ -558,6 +561,10 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request)
|
|||||||
if len(r.URL.Path) > len(prefix) && r.URL.Path[len(prefix)] != '/' {
|
if len(r.URL.Path) > len(prefix) && r.URL.Path[len(prefix)] != '/' {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
if r.URL.Path == prefix && prefix[len(prefix)-1] != '/' {
|
||||||
|
http.Redirect(rw, r, r.URL.Path+"/", 302)
|
||||||
|
goto Admin
|
||||||
|
}
|
||||||
file := path.Join(staticDir, r.URL.Path[len(prefix):])
|
file := path.Join(staticDir, r.URL.Path[len(prefix):])
|
||||||
finfo, err := os.Stat(file)
|
finfo, err := os.Stat(file)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user