fix #238
Showing
2 changed files
with
11 additions
and
0 deletions
| ... | @@ -5,6 +5,7 @@ import ( | ... | @@ -5,6 +5,7 @@ import ( |
| 5 | "github.com/astaxie/beego/session" | 5 | "github.com/astaxie/beego/session" |
| 6 | "net/http" | 6 | "net/http" |
| 7 | "path" | 7 | "path" |
| 8 | "strings" | ||
| 8 | ) | 9 | ) |
| 9 | 10 | ||
| 10 | const VERSION = "0.9.9" | 11 | const VERSION = "0.9.9" |
| ... | @@ -36,6 +37,9 @@ func SetViewsPath(path string) *App { | ... | @@ -36,6 +37,9 @@ func SetViewsPath(path string) *App { |
| 36 | } | 37 | } |
| 37 | 38 | ||
| 38 | func SetStaticPath(url string, path string) *App { | 39 | func SetStaticPath(url string, path string) *App { |
| 40 | if !strings.HasPrefix(url, "/") { | ||
| 41 | url = "/" + url | ||
| 42 | } | ||
| 39 | StaticDir[url] = path | 43 | StaticDir[url] = path |
| 40 | return BeeApp | 44 | return BeeApp |
| 41 | } | 45 | } | ... | ... |
| ... | @@ -8,6 +8,7 @@ import ( | ... | @@ -8,6 +8,7 @@ import ( |
| 8 | "path" | 8 | "path" |
| 9 | "runtime" | 9 | "runtime" |
| 10 | "strconv" | 10 | "strconv" |
| 11 | "strings" | ||
| 11 | ) | 12 | ) |
| 12 | 13 | ||
| 13 | var ( | 14 | var ( |
| ... | @@ -178,6 +179,12 @@ func ParseConfig() (err error) { | ... | @@ -178,6 +179,12 @@ func ParseConfig() (err error) { |
| 178 | if serverName := AppConfig.String("BeegoServerName"); serverName != "" { | 179 | if serverName := AppConfig.String("BeegoServerName"); serverName != "" { |
| 179 | BeegoServerName = serverName | 180 | BeegoServerName = serverName |
| 180 | } | 181 | } |
| 182 | if sd := AppConfig.String("StaticDir"); sd != "" { | ||
| 183 | sds := strings.Split(sd, ",") | ||
| 184 | for _, v := range sds { | ||
| 185 | StaticDir["/"+v] = v | ||
| 186 | } | ||
| 187 | } | ||
| 181 | } | 188 | } |
| 182 | return nil | 189 | return nil |
| 183 | } | 190 | } | ... | ... |
-
Please register or sign in to post a comment