diff --git a/README.md b/README.md index 86598f72..45e46743 100644 --- a/README.md +++ b/README.md @@ -34,8 +34,8 @@ Here is the canonical "Hello, world" example app for beego: } func main() { - beego.BeeApp.RegisterController("/", &MainController{}) - beego.BeeApp.Run() + beego.RegisterController("/", &MainController{}) + beego.Run() } default port:8080 @@ -56,16 +56,16 @@ in other way i has writing a tool to quick create an app based on beego. you can ============ 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: - beego.BeeApp.RegisterController("/", &controllers.MainController{}) - beego.BeeApp.RegisterController("/admin", &admin.UserController{}) - beego.BeeApp.RegisterController("/admin/index", &admin.ArticleController{}) - beego.BeeApp.RegisterController("/admin/addpkg", &admin.AddController{}) + beego.RegisterController("/", &controllers.MainController{}) + beego.RegisterController("/admin", &admin.UserController{}) + beego.RegisterController("/admin/index", &admin.ArticleController{}) + beego.RegisterController("/admin/addpkg", &admin.AddController{}) You can specify custom regular expressions for routes: - beego.BeeApp.RegisterController("/admin/editpkg/:id([0-9]+)", &admin.EditController{}) - beego.BeeApp.RegisterController("/admin/delpkg/:id([0-9]+)", &admin.DelController{}) - beego.BeeApp.RegisterController("/:pkg(.*)", &controllers.MainController{}) + beego.RegisterController("/admin/editpkg/:id([0-9]+)", &admin.EditController{}) + beego.RegisterController("/admin/delpkg/:id([0-9]+)", &admin.DelController{}) + beego.RegisterController("/:pkg(.*)", &controllers.MainController{}) You can also create routes for static files: @@ -85,18 +85,18 @@ You can, for example, filter all request to enforce some type of security: } } - beego.BeeApp.Filter(FilterUser) + beego.Filter(FilterUser) You can also apply filters only when certain REST URL Parameters exist: - beego.BeeApp.RegisterController("/:id([0-9]+)", &admin.EditController{}) - beego.BeeApp.FilterParam("id", func(rw http.ResponseWriter, r *http.Request) { + beego.RegisterController("/:id([0-9]+)", &admin.EditController{}) + beego.FilterParam("id", func(rw http.ResponseWriter, r *http.Request) { ... }) also You can apply filters only when certain prefix URL path exist: - beego.BeeApp.FilterPrefixPath("/admin", func(rw http.ResponseWriter, r *http.Request) { + beego.FilterPrefixPath("/admin", func(rw http.ResponseWriter, r *http.Request) { … auth }) diff --git a/beego.go b/beego.go index c196934c..9c5f343e 100644 --- a/beego.go +++ b/beego.go @@ -125,3 +125,27 @@ func (app *App) ErrorLog(ctx *Context) { func (app *App) AccessLog(ctx *Context) { BeeLogger.Printf("[ACC] host: '%s', request: '%s %s', proto: '%s', ua: %s'', remote: '%s'\n", ctx.Request.Host, ctx.Request.Method, ctx.Request.URL.Path, ctx.Request.Proto, ctx.Request.UserAgent(), ctx.Request.RemoteAddr) } + +func RegisterController(path string, c ControllerInterface) *App { + BeeApp.RegisterController(path, c) + return BeeApp +} + +func Filter(filter http.HandlerFunc) *App { + BeeApp.Filter(filter) + return BeeApp +} + +func FilterParam(param string, filter http.HandlerFunc) *App { + BeeApp.FilterParam(param, filter) + return BeeApp +} + +func FilterPrefixPath(path string, filter http.HandlerFunc) *App { + BeeApp.FilterParam(path, filter) + return BeeApp +} + +func Run() { + BeeApp.Run() +} diff --git a/controller.go b/controller.go index fdd826a7..66b664db 100644 --- a/controller.go +++ b/controller.go @@ -7,6 +7,7 @@ import ( "html/template" "io/ioutil" "net/http" + "net/url" "path" "strconv" ) @@ -145,3 +146,8 @@ func (c *Controller) ServeXml() { c.Ct.ContentType("xml") c.Ct.ResponseWriter.Write(content) } + +func (c *Controller) Input() url.Values { + c.Ct.Request.ParseForm() + return c.Ct.Request.Form +} diff --git a/model.go b/model.go index 66bad313..74e37f9d 100644 --- a/model.go +++ b/model.go @@ -1 +1,36 @@ -package beego \ No newline at end of file +package beego + +type BeeModel struct { + driver string +} + +func (this *BeeModel) Insert() { + +} + +func (this *BeeModel) MultipleInsert() { + +} + +func (this *BeeModel) Update() { + +} + +func (this *BeeModel) Query() { + +} + +//Deletes from table with clauses where and using. +func (this *BeeModel) Delete() { + +} + +//Start a transaction +func (this *BeeModel) Transaction() { + +} + +//commit transaction +func (this *BeeModel) Commit() { + +}