Fix section "Static routing" in 13.2.md

This commit is contained in:
Anchor
2015-01-20 10:21:18 -08:00
committed by James Miranda
parent 9f6094d703
commit c06efdc2e6

View File

@@ -124,14 +124,14 @@ Its detailed implementation is as follows:
### Static routing
Above we achieve the realization of dynamic routing, Go the http package supported by default static file handler FileServer, because we have implemented a custom router, then the static files also need to set their own, beego static folder path stored in the global variable StaticDir, StaticDir is a map type to achieve the following:
We've implemented dynamic routing in our example above. By default, Go's `http` package supports serving static files with `http.FileServer`, which return a `Handler`. Since we have implemented a custom router, we will also need a way of handling static files. Beego's static folder path is saved in a global variable called `StaticDir`, which maps URL to corresponding paths. The `SetStaticPath`'s implementation can be seen below:
func (app *App) SetStaticPath(url string, path string) *App {
StaticDir[url] = path
return app
}
Applications can use the static route is set to achieve the following manner:
The application's static routes can be set like so:
beego.SetStaticPath("/img", "/static/img")