|
|
|
|
@@ -317,6 +317,7 @@ func RouterWithOpts(rootpath string, c ControllerInterface, opts ...ControllerOp
|
|
|
|
|
// Router adds a patterned controller handler to BeeApp.
|
|
|
|
|
// it's an alias method of HttpServer.Router.
|
|
|
|
|
// usage:
|
|
|
|
|
//
|
|
|
|
|
// simple router
|
|
|
|
|
// beego.Router("/admin", &admin.UserController{})
|
|
|
|
|
// beego.Router("/admin/index", &admin.ArticleController{})
|
|
|
|
|
@@ -351,6 +352,7 @@ func UnregisterFixedRoute(fixedRoute string, method string) *HttpServer {
|
|
|
|
|
// method type (e.g. "GET" or "POST") for selective removal.
|
|
|
|
|
//
|
|
|
|
|
// Usage (replace "GET" with "*" for all methods):
|
|
|
|
|
//
|
|
|
|
|
// beego.UnregisterFixedRoute("/yourpreviouspath", "GET")
|
|
|
|
|
// beego.Router("/yourpreviouspath", yourControllerAddress, "get:GetNewPage")
|
|
|
|
|
func (app *HttpServer) UnregisterFixedRoute(fixedRoute string, method string) *HttpServer {
|
|
|
|
|
@@ -430,23 +432,26 @@ func Include(cList ...ControllerInterface) *HttpServer {
|
|
|
|
|
// Include will generate router file in the router/xxx.go from the controller's comments
|
|
|
|
|
// usage:
|
|
|
|
|
// beego.Include(&BankAccount{}, &OrderController{},&RefundController{},&ReceiptController{})
|
|
|
|
|
//
|
|
|
|
|
// type BankAccount struct{
|
|
|
|
|
// beego.Controller
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// register the function
|
|
|
|
|
//
|
|
|
|
|
// func (b *BankAccount)Mapping(){
|
|
|
|
|
// b.Mapping("ShowAccount" , b.ShowAccount)
|
|
|
|
|
// b.Mapping("ModifyAccount", b.ModifyAccount)
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// //@router /account/:id [get]
|
|
|
|
|
//
|
|
|
|
|
// func (b *BankAccount) ShowAccount(){
|
|
|
|
|
// //logic
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
// //@router /account/:id [post]
|
|
|
|
|
//
|
|
|
|
|
// func (b *BankAccount) ModifyAccount(){
|
|
|
|
|
// //logic
|
|
|
|
|
// }
|
|
|
|
|
@@ -508,6 +513,7 @@ func CtrlGet(rootpath string, f interface{}) {
|
|
|
|
|
|
|
|
|
|
// CtrlGet used to register router for CtrlGet method
|
|
|
|
|
// usage:
|
|
|
|
|
//
|
|
|
|
|
// type MyController struct {
|
|
|
|
|
// web.Controller
|
|
|
|
|
// }
|
|
|
|
|
@@ -528,6 +534,7 @@ func CtrlPost(rootpath string, f interface{}) {
|
|
|
|
|
|
|
|
|
|
// CtrlPost used to register router for CtrlPost method
|
|
|
|
|
// usage:
|
|
|
|
|
//
|
|
|
|
|
// type MyController struct {
|
|
|
|
|
// web.Controller
|
|
|
|
|
// }
|
|
|
|
|
@@ -548,6 +555,7 @@ func CtrlHead(rootpath string, f interface{}) {
|
|
|
|
|
|
|
|
|
|
// CtrlHead used to register router for CtrlHead method
|
|
|
|
|
// usage:
|
|
|
|
|
//
|
|
|
|
|
// type MyController struct {
|
|
|
|
|
// web.Controller
|
|
|
|
|
// }
|
|
|
|
|
@@ -568,6 +576,7 @@ func CtrlPut(rootpath string, f interface{}) {
|
|
|
|
|
|
|
|
|
|
// CtrlPut used to register router for CtrlPut method
|
|
|
|
|
// usage:
|
|
|
|
|
//
|
|
|
|
|
// type MyController struct {
|
|
|
|
|
// web.Controller
|
|
|
|
|
// }
|
|
|
|
|
@@ -588,6 +597,7 @@ func CtrlPatch(rootpath string, f interface{}) {
|
|
|
|
|
|
|
|
|
|
// CtrlPatch used to register router for CtrlPatch method
|
|
|
|
|
// usage:
|
|
|
|
|
//
|
|
|
|
|
// type MyController struct {
|
|
|
|
|
// web.Controller
|
|
|
|
|
// }
|
|
|
|
|
@@ -608,6 +618,7 @@ func CtrlDelete(rootpath string, f interface{}) {
|
|
|
|
|
|
|
|
|
|
// CtrlDelete used to register router for CtrlDelete method
|
|
|
|
|
// usage:
|
|
|
|
|
//
|
|
|
|
|
// type MyController struct {
|
|
|
|
|
// web.Controller
|
|
|
|
|
// }
|
|
|
|
|
@@ -628,6 +639,7 @@ func CtrlOptions(rootpath string, f interface{}) {
|
|
|
|
|
|
|
|
|
|
// CtrlOptions used to register router for CtrlOptions method
|
|
|
|
|
// usage:
|
|
|
|
|
//
|
|
|
|
|
// type MyController struct {
|
|
|
|
|
// web.Controller
|
|
|
|
|
// }
|
|
|
|
|
@@ -648,6 +660,7 @@ func CtrlAny(rootpath string, f interface{}) {
|
|
|
|
|
|
|
|
|
|
// CtrlAny used to register router for CtrlAny method
|
|
|
|
|
// usage:
|
|
|
|
|
//
|
|
|
|
|
// type MyController struct {
|
|
|
|
|
// web.Controller
|
|
|
|
|
// }
|
|
|
|
|
@@ -668,6 +681,7 @@ func Get(rootpath string, f HandleFunc) *HttpServer {
|
|
|
|
|
|
|
|
|
|
// Get used to register router for Get method
|
|
|
|
|
// usage:
|
|
|
|
|
//
|
|
|
|
|
// beego.Get("/", func(ctx *context.Context){
|
|
|
|
|
// ctx.Output.Body("hello world")
|
|
|
|
|
// })
|
|
|
|
|
@@ -683,6 +697,7 @@ func Post(rootpath string, f HandleFunc) *HttpServer {
|
|
|
|
|
|
|
|
|
|
// Post used to register router for Post method
|
|
|
|
|
// usage:
|
|
|
|
|
//
|
|
|
|
|
// beego.Post("/api", func(ctx *context.Context){
|
|
|
|
|
// ctx.Output.Body("hello world")
|
|
|
|
|
// })
|
|
|
|
|
@@ -698,6 +713,7 @@ func Delete(rootpath string, f HandleFunc) *HttpServer {
|
|
|
|
|
|
|
|
|
|
// Delete used to register router for Delete method
|
|
|
|
|
// usage:
|
|
|
|
|
//
|
|
|
|
|
// beego.Delete("/api", func(ctx *context.Context){
|
|
|
|
|
// ctx.Output.Body("hello world")
|
|
|
|
|
// })
|
|
|
|
|
@@ -713,6 +729,7 @@ func Put(rootpath string, f HandleFunc) *HttpServer {
|
|
|
|
|
|
|
|
|
|
// Put used to register router for Put method
|
|
|
|
|
// usage:
|
|
|
|
|
//
|
|
|
|
|
// beego.Put("/api", func(ctx *context.Context){
|
|
|
|
|
// ctx.Output.Body("hello world")
|
|
|
|
|
// })
|
|
|
|
|
@@ -728,6 +745,7 @@ func Head(rootpath string, f HandleFunc) *HttpServer {
|
|
|
|
|
|
|
|
|
|
// Head used to register router for Head method
|
|
|
|
|
// usage:
|
|
|
|
|
//
|
|
|
|
|
// beego.Head("/api", func(ctx *context.Context){
|
|
|
|
|
// ctx.Output.Body("hello world")
|
|
|
|
|
// })
|
|
|
|
|
@@ -744,6 +762,7 @@ func Options(rootpath string, f HandleFunc) *HttpServer {
|
|
|
|
|
|
|
|
|
|
// Options used to register router for Options method
|
|
|
|
|
// usage:
|
|
|
|
|
//
|
|
|
|
|
// beego.Options("/api", func(ctx *context.Context){
|
|
|
|
|
// ctx.Output.Body("hello world")
|
|
|
|
|
// })
|
|
|
|
|
@@ -759,6 +778,7 @@ func Patch(rootpath string, f HandleFunc) *HttpServer {
|
|
|
|
|
|
|
|
|
|
// Patch used to register router for Patch method
|
|
|
|
|
// usage:
|
|
|
|
|
//
|
|
|
|
|
// beego.Patch("/api", func(ctx *context.Context){
|
|
|
|
|
// ctx.Output.Body("hello world")
|
|
|
|
|
// })
|
|
|
|
|
@@ -774,6 +794,7 @@ func Any(rootpath string, f HandleFunc) *HttpServer {
|
|
|
|
|
|
|
|
|
|
// Any used to register router for all methods
|
|
|
|
|
// usage:
|
|
|
|
|
//
|
|
|
|
|
// beego.Any("/api", func(ctx *context.Context){
|
|
|
|
|
// ctx.Output.Body("hello world")
|
|
|
|
|
// })
|
|
|
|
|
@@ -789,6 +810,7 @@ func Handler(rootpath string, h http.Handler, options ...interface{}) *HttpServe
|
|
|
|
|
|
|
|
|
|
// Handler used to register a Handler router
|
|
|
|
|
// usage:
|
|
|
|
|
//
|
|
|
|
|
// beego.Handler("/api", http.HandlerFunc(func (w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
// fmt.Fprintf(w, "Hello, %q", html.EscapeString(r.URL.Path))
|
|
|
|
|
// }))
|
|
|
|
|
@@ -797,7 +819,7 @@ func (app *HttpServer) Handler(rootpath string, h http.Handler, options ...inter
|
|
|
|
|
return app
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// InserFilter see HttpServer.InsertFilter
|
|
|
|
|
// InsertFilter see HttpServer.InsertFilter
|
|
|
|
|
func InsertFilter(pattern string, pos int, filter FilterFunc, opts ...FilterOpt) *HttpServer {
|
|
|
|
|
return BeeApp.InsertFilter(pattern, pos, filter, opts...)
|
|
|
|
|
}
|
|
|
|
|
|