1
0
mirror of https://github.com/beego/bee.git synced 2024-11-22 15:10:54 +00:00

Merge pull request #83 from tossp/swagger

添加常量Rootinfo和Subapi
This commit is contained in:
astaxie 2014-11-21 13:14:59 +08:00
commit 0f0a217752

View File

@ -45,19 +45,21 @@ import (
"github.com/astaxie/beego/swagger" "github.com/astaxie/beego/swagger"
) )
var rootinfo string = {{.rootinfo}} const (
var subapi string = {{.subapi}} Rootinfo string = {{.rootinfo}}
var rootapi swagger.ResourceListing Subapi string = {{.subapi}}
BasePath string= "{{.version}}"
)
var rootapi swagger.ResourceListing
var apilist map[string]*swagger.ApiDeclaration var apilist map[string]*swagger.ApiDeclaration
func init() { func init() {
basepath := "{{.version}}" err := json.Unmarshal([]byte(Rootinfo), &rootapi)
err := json.Unmarshal([]byte(rootinfo), &rootapi)
if err != nil { if err != nil {
beego.Error(err) beego.Error(err)
} }
err = json.Unmarshal([]byte(subapi), &apilist) err = json.Unmarshal([]byte(Subapi), &apilist)
if err != nil { if err != nil {
beego.Error(err) beego.Error(err)
} }
@ -67,7 +69,7 @@ func init() {
a.Path = urlReplace(k + a.Path) a.Path = urlReplace(k + a.Path)
v.Apis[i] = a v.Apis[i] = a
} }
v.BasePath = basepath v.BasePath = BasePath
beego.GlobalDocApi[strings.Trim(k, "/")] = v beego.GlobalDocApi[strings.Trim(k, "/")] = v
} }
} }