mirror of
https://github.com/astaxie/beego.git
synced 2024-11-25 04:50:56 +00:00
enhance the static file path. If user foget / path.Join will auto fix it.
This commit is contained in:
parent
62555771d0
commit
04a19685ed
@ -8,6 +8,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
|
"path"
|
||||||
"reflect"
|
"reflect"
|
||||||
"regexp"
|
"regexp"
|
||||||
"runtime"
|
"runtime"
|
||||||
@ -546,13 +547,13 @@ 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 r.URL.Path == "/favicon.ico" {
|
if r.URL.Path == "/favicon.ico" {
|
||||||
file := staticDir + r.URL.Path
|
file := path.Join(staticDir, r.URL.Path)
|
||||||
http.ServeFile(w, r, file)
|
http.ServeFile(w, r, file)
|
||||||
w.started = true
|
w.started = true
|
||||||
goto Admin
|
goto Admin
|
||||||
}
|
}
|
||||||
if strings.HasPrefix(r.URL.Path, prefix) {
|
if strings.HasPrefix(r.URL.Path, prefix) {
|
||||||
file := 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 {
|
||||||
if RunMode == "dev" {
|
if RunMode == "dev" {
|
||||||
|
Loading…
Reference in New Issue
Block a user