7da0e580 by xiemengjun

继续完善文档

1 parent 7526b9df
Showing 1 changed file with 30 additions and 3 deletions
1 Beego 1 ## Beego
2 ======= 2 =======
3 Beego is an open source version of the scalable, non-blocking web server 3 Beego is an open source version of the scalable, non-blocking web server
4 and tools that power SNDA's CDN system. Documentation and downloads are 4 and tools that power SNDA's CDN system. Documentation and downloads are
...@@ -7,7 +7,7 @@ available at https://github.com/astaxie/beego ...@@ -7,7 +7,7 @@ available at https://github.com/astaxie/beego
7 Beego is licensed under the Apache Licence, Version 2.0 7 Beego is licensed under the Apache Licence, Version 2.0
8 (http://www.apache.org/licenses/LICENSE-2.0.html). 8 (http://www.apache.org/licenses/LICENSE-2.0.html).
9 9
10 Installation 10 ## Installation
11 ============ 11 ============
12 To install: 12 To install:
13 13
...@@ -15,7 +15,7 @@ To install: ...@@ -15,7 +15,7 @@ To install:
15 15
16 go version: go1 release 16 go version: go1 release
17 17
18 Quick Start 18 ## Quick Start
19 ============ 19 ============
20 Here is the canonical "Hello, world" example app for beego: 20 Here is the canonical "Hello, world" example app for beego:
21 21
...@@ -47,3 +47,30 @@ default port:8080 ...@@ -47,3 +47,30 @@ default port:8080
47 Transfer-Encoding: chunked 47 Transfer-Encoding: chunked
48 48
49 hello world 49 hello world
50
51
52 ## Router
53 ============
54 In beego, a route is a struct paired with a URL-matching pattern. The strcut has many method with the same name of http method to server the http request. Each route is associated with a block:
55
56 beego.BeeApp.RegisterController("/", &controllers.MainController{})
57 beego.BeeApp.RegisterController("/admin", &admin.UserController{})
58 beego.BeeApp.RegisterController("/admin/index", &admin.ArticleController{})
59 beego.BeeApp.RegisterController("/admin/addpkg", &admin.AddController{})
60
61 You can specify custom regular expressions for routes:
62
63 beego.BeeApp.RegisterController("/admin/editpkg/:id([0-9]+)", &admin.EditController{})
64 beego.BeeApp.RegisterController("/admin/delpkg/:id([0-9]+)", &admin.DelController{})
65 beego.BeeApp.RegisterController("/:pkg(.*)", &controllers.MainController{})
66
67 You can also create routes for static files:
68
69 beego.BeeApp.SetStaticPath("/static","/public")
70
71 this will serve any files in /static, including files in subdirectories. For example request `/static/logo.gif` or `/static/style/main.css` will server with the file in the path `/pulic/logo.gif` or `/public/style/main.css`
72
73 ## Filters / Middleware
74 ============
75
76
...\ No newline at end of file ...\ No newline at end of file
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!