From c1b2e1d0ca6b0593ea743a80fe607cd8674df088 Mon Sep 17 00:00:00 2001 From: astaxie Date: Mon, 28 Oct 2013 23:30:16 +0800 Subject: [PATCH] fix #238 --- beego.go | 4 ++++ config.go | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/beego.go b/beego.go index c58302c3..5eb69a6c 100644 --- a/beego.go +++ b/beego.go @@ -5,6 +5,7 @@ import ( "github.com/astaxie/beego/session" "net/http" "path" + "strings" ) const VERSION = "0.9.9" @@ -36,6 +37,9 @@ func SetViewsPath(path string) *App { } func SetStaticPath(url string, path string) *App { + if !strings.HasPrefix(url, "/") { + url = "/" + url + } StaticDir[url] = path return BeeApp } diff --git a/config.go b/config.go index 28b81160..8efe09d9 100644 --- a/config.go +++ b/config.go @@ -8,6 +8,7 @@ import ( "path" "runtime" "strconv" + "strings" ) var ( @@ -178,6 +179,12 @@ func ParseConfig() (err error) { if serverName := AppConfig.String("BeegoServerName"); serverName != "" { BeegoServerName = serverName } + if sd := AppConfig.String("StaticDir"); sd != "" { + sds := strings.Split(sd, ",") + for _, v := range sds { + StaticDir["/"+v] = v + } + } } return nil }