Merge pull request #4364 from flycash/develop

Fix 4363
This commit is contained in:
Ming Deng 2020-12-16 10:09:06 +08:00 committed by GitHub
commit a3be4cd7c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -238,141 +238,158 @@ func AddNamespace(nl ...*Namespace) {
// NSCond is Namespace Condition // NSCond is Namespace Condition
func NSCond(cond namespaceCond) LinkNamespace { func NSCond(cond namespaceCond) LinkNamespace {
wc := web.NSCond(func(b *context.Context) bool {
return cond((*adtContext.Context)(b))
})
return func(namespace *Namespace) { return func(namespace *Namespace) {
web.NSCond(func(b *context.Context) bool { wc((*web.Namespace)(namespace))
return cond((*adtContext.Context)(b))
})
} }
} }
// NSBefore Namespace BeforeRouter filter // NSBefore Namespace BeforeRouter filter
func NSBefore(filterList ...FilterFunc) LinkNamespace { func NSBefore(filterList ...FilterFunc) LinkNamespace {
nfs := oldToNewFilter(filterList)
wf := web.NSBefore(nfs...)
return func(namespace *Namespace) { return func(namespace *Namespace) {
nfs := oldToNewFilter(filterList) wf((*web.Namespace)(namespace))
web.NSBefore(nfs...)
} }
} }
// NSAfter add Namespace FinishRouter filter // NSAfter add Namespace FinishRouter filter
func NSAfter(filterList ...FilterFunc) LinkNamespace { func NSAfter(filterList ...FilterFunc) LinkNamespace {
nfs := oldToNewFilter(filterList)
wf := web.NSAfter(nfs...)
return func(namespace *Namespace) { return func(namespace *Namespace) {
nfs := oldToNewFilter(filterList) wf((*web.Namespace)(namespace))
web.NSAfter(nfs...)
} }
} }
// NSInclude Namespace Include ControllerInterface // NSInclude Namespace Include ControllerInterface
func NSInclude(cList ...ControllerInterface) LinkNamespace { func NSInclude(cList ...ControllerInterface) LinkNamespace {
nfs := oldToNewCtrlIntfs(cList)
wi := web.NSInclude(nfs...)
return func(namespace *Namespace) { return func(namespace *Namespace) {
nfs := oldToNewCtrlIntfs(cList) wi((*web.Namespace)(namespace))
web.NSInclude(nfs...)
} }
} }
// NSRouter call Namespace Router // NSRouter call Namespace Router
func NSRouter(rootpath string, c ControllerInterface, mappingMethods ...string) LinkNamespace { func NSRouter(rootpath string, c ControllerInterface, mappingMethods ...string) LinkNamespace {
wn := web.NSRouter(rootpath, c, mappingMethods...)
return func(namespace *Namespace) { return func(namespace *Namespace) {
web.Router(rootpath, c, mappingMethods...) wn((*web.Namespace)(namespace))
} }
} }
// NSGet call Namespace Get // NSGet call Namespace Get
func NSGet(rootpath string, f FilterFunc) LinkNamespace { func NSGet(rootpath string, f FilterFunc) LinkNamespace {
ln := web.NSGet(rootpath, func(ctx *context.Context) {
f((*adtContext.Context)(ctx))
})
return func(ns *Namespace) { return func(ns *Namespace) {
web.NSGet(rootpath, func(ctx *context.Context) { ln((*web.Namespace)(ns))
f((*adtContext.Context)(ctx))
})
} }
} }
// NSPost call Namespace Post // NSPost call Namespace Post
func NSPost(rootpath string, f FilterFunc) LinkNamespace { func NSPost(rootpath string, f FilterFunc) LinkNamespace {
wp := web.NSPost(rootpath, func(ctx *context.Context) {
f((*adtContext.Context)(ctx))
})
return func(ns *Namespace) { return func(ns *Namespace) {
web.Post(rootpath, func(ctx *context.Context) { wp((*web.Namespace)(ns))
f((*adtContext.Context)(ctx))
})
} }
} }
// NSHead call Namespace Head // NSHead call Namespace Head
func NSHead(rootpath string, f FilterFunc) LinkNamespace { func NSHead(rootpath string, f FilterFunc) LinkNamespace {
wb := web.NSHead(rootpath, func(ctx *context.Context) {
f((*adtContext.Context)(ctx))
})
return func(ns *Namespace) { return func(ns *Namespace) {
web.NSHead(rootpath, func(ctx *context.Context) { wb((*web.Namespace)(ns))
f((*adtContext.Context)(ctx))
})
} }
} }
// NSPut call Namespace Put // NSPut call Namespace Put
func NSPut(rootpath string, f FilterFunc) LinkNamespace { func NSPut(rootpath string, f FilterFunc) LinkNamespace {
wn := web.NSPut(rootpath, func(ctx *context.Context) {
f((*adtContext.Context)(ctx))
})
return func(ns *Namespace) { return func(ns *Namespace) {
web.NSPut(rootpath, func(ctx *context.Context) { wn((*web.Namespace)(ns))
f((*adtContext.Context)(ctx))
})
} }
} }
// NSDelete call Namespace Delete // NSDelete call Namespace Delete
func NSDelete(rootpath string, f FilterFunc) LinkNamespace { func NSDelete(rootpath string, f FilterFunc) LinkNamespace {
wn := web.NSDelete(rootpath, func(ctx *context.Context) {
f((*adtContext.Context)(ctx))
})
return func(ns *Namespace) { return func(ns *Namespace) {
web.NSDelete(rootpath, func(ctx *context.Context) { wn((*web.Namespace)(ns))
f((*adtContext.Context)(ctx))
})
} }
} }
// NSAny call Namespace Any // NSAny call Namespace Any
func NSAny(rootpath string, f FilterFunc) LinkNamespace { func NSAny(rootpath string, f FilterFunc) LinkNamespace {
wn := web.NSAny(rootpath, func(ctx *context.Context) {
f((*adtContext.Context)(ctx))
})
return func(ns *Namespace) { return func(ns *Namespace) {
web.NSAny(rootpath, func(ctx *context.Context) { wn((*web.Namespace)(ns))
f((*adtContext.Context)(ctx))
})
} }
} }
// NSOptions call Namespace Options // NSOptions call Namespace Options
func NSOptions(rootpath string, f FilterFunc) LinkNamespace { func NSOptions(rootpath string, f FilterFunc) LinkNamespace {
wo := web.NSOptions(rootpath, func(ctx *context.Context) {
f((*adtContext.Context)(ctx))
})
return func(ns *Namespace) { return func(ns *Namespace) {
web.NSOptions(rootpath, func(ctx *context.Context) { wo((*web.Namespace)(ns))
f((*adtContext.Context)(ctx))
})
} }
} }
// NSPatch call Namespace Patch // NSPatch call Namespace Patch
func NSPatch(rootpath string, f FilterFunc) LinkNamespace { func NSPatch(rootpath string, f FilterFunc) LinkNamespace {
wn := web.NSPatch(rootpath, func(ctx *context.Context) {
f((*adtContext.Context)(ctx))
})
return func(ns *Namespace) { return func(ns *Namespace) {
web.NSPatch(rootpath, func(ctx *context.Context) { wn((*web.Namespace)(ns))
f((*adtContext.Context)(ctx))
})
} }
} }
// NSAutoRouter call Namespace AutoRouter // NSAutoRouter call Namespace AutoRouter
func NSAutoRouter(c ControllerInterface) LinkNamespace { func NSAutoRouter(c ControllerInterface) LinkNamespace {
wn := web.NSAutoRouter(c)
return func(ns *Namespace) { return func(ns *Namespace) {
web.NSAutoRouter(c) wn((*web.Namespace)(ns))
} }
} }
// NSAutoPrefix call Namespace AutoPrefix // NSAutoPrefix call Namespace AutoPrefix
func NSAutoPrefix(prefix string, c ControllerInterface) LinkNamespace { func NSAutoPrefix(prefix string, c ControllerInterface) LinkNamespace {
wn := web.NSAutoPrefix(prefix, c)
return func(ns *Namespace) { return func(ns *Namespace) {
web.NSAutoPrefix(prefix, c) wn((*web.Namespace)(ns))
} }
} }
// NSNamespace add sub Namespace // NSNamespace add sub Namespace
func NSNamespace(prefix string, params ...LinkNamespace) LinkNamespace { func NSNamespace(prefix string, params ...LinkNamespace) LinkNamespace {
nps := oldToNewLinkNs(params)
wn := web.NSNamespace(prefix, nps...)
return func(ns *Namespace) { return func(ns *Namespace) {
nps := oldToNewLinkNs(params) wn((*web.Namespace)(ns))
web.NSNamespace(prefix, nps...)
} }
} }
// NSHandler add handler // NSHandler add handler
func NSHandler(rootpath string, h http.Handler) LinkNamespace { func NSHandler(rootpath string, h http.Handler) LinkNamespace {
wn := web.NSHandler(rootpath, h)
return func(ns *Namespace) { return func(ns *Namespace) {
web.NSHandler(rootpath, h) wn((*web.Namespace)(ns))
} }
} }