1
0
mirror of https://github.com/astaxie/beego.git synced 2025-07-04 09:40: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:
astaxie
2014-05-16 23:47:15 +08:00
parent 2ed9b2bffd
commit e657dcfd5f
5 changed files with 294 additions and 5 deletions

View File

@ -170,8 +170,8 @@ func Any(rootpath string, f FilterFunc) *App {
}
// register router for own Handler
func Handler(rootpath string, h http.Handler) *App {
BeeApp.Handler(rootpath, h)
func Handler(rootpath string, h http.Handler, options ...interface{}) *App {
BeeApp.Handler(rootpath, h, options...)
return BeeApp
}