mirror of
https://github.com/astaxie/beego.git
synced 2025-07-03 13:30:19 +00:00
beego: support namespace
ns := beego.NewNamespace("/v1/api/") ns.Cond(func(ctx *context.Context)bool{ if ctx.Input.Domain() == "www.beego.me" { return true } return false }) .Filter("before", Authenticate) .Router("/order", &admin.OrderController{}) .Get("/version",func (ctx *context.Context) { ctx.Output.Body([]byte("1.0.0")) }) .Post("/login",func (ctx *context.Context) { if ctx.Query("username") == "admin" && ctx.Query("username") == "password" { } }) .Namespace( NewNamespace("/shop"). Get("/order/:id", func(ctx *context.Context) { ctx.Output.Body([]byte(ctx.Input.Param(":id"))) }), )
This commit is contained in:
4
app.go
4
app.go
@ -185,8 +185,8 @@ func (app *App) Any(rootpath string, f FilterFunc) *App {
|
||||
}
|
||||
|
||||
// add router for http.Handler
|
||||
func (app *App) Handler(rootpath string, h http.Handler) *App {
|
||||
app.Handlers.Handler(rootpath, h)
|
||||
func (app *App) Handler(rootpath string, h http.Handler, options ...interface{}) *App {
|
||||
app.Handlers.Handler(rootpath, h, options...)
|
||||
return app
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user