mirror of
https://github.com/astaxie/beego.git
synced 2024-11-01 02:30:55 +00:00
fix bug for static file like /static /static_js /static_css
This commit is contained in:
parent
217c3a2e87
commit
6c92ca2a16
11
router.go
11
router.go
@ -548,11 +548,16 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request)
|
|||||||
for prefix, staticDir := range StaticDir {
|
for prefix, staticDir := range StaticDir {
|
||||||
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)
|
||||||
http.ServeFile(w, r, file)
|
if utils.FileExists(file) {
|
||||||
w.started = true
|
http.ServeFile(w, r, file)
|
||||||
goto Admin
|
w.started = true
|
||||||
|
goto Admin
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if strings.HasPrefix(r.URL.Path, prefix) {
|
if strings.HasPrefix(r.URL.Path, prefix) {
|
||||||
|
if len(r.URL.Path) > len(prefix) && r.URL.Path[len(prefix)+1] != '/' {
|
||||||
|
continue
|
||||||
|
}
|
||||||
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