Fix adapter namespace don't work BUG

This commit is contained in:
Ming Deng 2020-12-15 22:22:48 +08:00
parent 385e1d390f
commit b64a1e73ed

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 {
return func(namespace *Namespace) { wc := web.NSCond(func(b *context.Context) bool {
web.NSCond(func(b *context.Context) bool {
return cond((*adtContext.Context)(b)) return cond((*adtContext.Context)(b))
}) })
return func(namespace *Namespace) {
wc((*web.Namespace)(namespace))
} }
} }
// NSBefore Namespace BeforeRouter filter // NSBefore Namespace BeforeRouter filter
func NSBefore(filterList ...FilterFunc) LinkNamespace { func NSBefore(filterList ...FilterFunc) LinkNamespace {
return func(namespace *Namespace) {
nfs := oldToNewFilter(filterList) nfs := oldToNewFilter(filterList)
web.NSBefore(nfs...) wf := web.NSBefore(nfs...)
return func(namespace *Namespace) {
wf((*web.Namespace)(namespace))
} }
} }
// NSAfter add Namespace FinishRouter filter // NSAfter add Namespace FinishRouter filter
func NSAfter(filterList ...FilterFunc) LinkNamespace { func NSAfter(filterList ...FilterFunc) LinkNamespace {
return func(namespace *Namespace) {
nfs := oldToNewFilter(filterList) nfs := oldToNewFilter(filterList)
web.NSAfter(nfs...) wf := web.NSAfter(nfs...)
return func(namespace *Namespace) {
wf((*web.Namespace)(namespace))
} }
} }
// NSInclude Namespace Include ControllerInterface // NSInclude Namespace Include ControllerInterface
func NSInclude(cList ...ControllerInterface) LinkNamespace { func NSInclude(cList ...ControllerInterface) LinkNamespace {
return func(namespace *Namespace) {
nfs := oldToNewCtrlIntfs(cList) nfs := oldToNewCtrlIntfs(cList)
web.NSInclude(nfs...) wi := web.NSInclude(nfs...)
return func(namespace *Namespace) {
wi((*web.Namespace)(namespace))
} }
} }
// 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 {
return func(ns *Namespace) { ln := web.NSGet(rootpath, func(ctx *context.Context) {
web.NSGet(rootpath, func(ctx *context.Context) {
f((*adtContext.Context)(ctx)) f((*adtContext.Context)(ctx))
}) })
return func(ns *Namespace) {
ln((*web.Namespace)(ns))
} }
} }
// NSPost call Namespace Post // NSPost call Namespace Post
func NSPost(rootpath string, f FilterFunc) LinkNamespace { func NSPost(rootpath string, f FilterFunc) LinkNamespace {
return func(ns *Namespace) { wp := web.NSPost(rootpath, func(ctx *context.Context) {
web.Post(rootpath, func(ctx *context.Context) {
f((*adtContext.Context)(ctx)) f((*adtContext.Context)(ctx))
}) })
return func(ns *Namespace) {
wp((*web.Namespace)(ns))
} }
} }
// NSHead call Namespace Head // NSHead call Namespace Head
func NSHead(rootpath string, f FilterFunc) LinkNamespace { func NSHead(rootpath string, f FilterFunc) LinkNamespace {
return func(ns *Namespace) { wb := web.NSHead(rootpath, func(ctx *context.Context) {
web.NSHead(rootpath, func(ctx *context.Context) {
f((*adtContext.Context)(ctx)) f((*adtContext.Context)(ctx))
}) })
return func(ns *Namespace) {
wb((*web.Namespace)(ns))
} }
} }
// NSPut call Namespace Put // NSPut call Namespace Put
func NSPut(rootpath string, f FilterFunc) LinkNamespace { func NSPut(rootpath string, f FilterFunc) LinkNamespace {
return func(ns *Namespace) { wn := web.NSPut(rootpath, func(ctx *context.Context) {
web.NSPut(rootpath, func(ctx *context.Context) {
f((*adtContext.Context)(ctx)) f((*adtContext.Context)(ctx))
}) })
return func(ns *Namespace) {
wn((*web.Namespace)(ns))
} }
} }
// NSDelete call Namespace Delete // NSDelete call Namespace Delete
func NSDelete(rootpath string, f FilterFunc) LinkNamespace { func NSDelete(rootpath string, f FilterFunc) LinkNamespace {
return func(ns *Namespace) { wn := web.NSDelete(rootpath, func(ctx *context.Context) {
web.NSDelete(rootpath, func(ctx *context.Context) {
f((*adtContext.Context)(ctx)) f((*adtContext.Context)(ctx))
}) })
return func(ns *Namespace) {
wn((*web.Namespace)(ns))
} }
} }
// NSAny call Namespace Any // NSAny call Namespace Any
func NSAny(rootpath string, f FilterFunc) LinkNamespace { func NSAny(rootpath string, f FilterFunc) LinkNamespace {
return func(ns *Namespace) { wn := web.NSAny(rootpath, func(ctx *context.Context) {
web.NSAny(rootpath, func(ctx *context.Context) {
f((*adtContext.Context)(ctx)) f((*adtContext.Context)(ctx))
}) })
return func(ns *Namespace) {
wn((*web.Namespace)(ns))
} }
} }
// NSOptions call Namespace Options // NSOptions call Namespace Options
func NSOptions(rootpath string, f FilterFunc) LinkNamespace { func NSOptions(rootpath string, f FilterFunc) LinkNamespace {
return func(ns *Namespace) { wo := web.NSOptions(rootpath, func(ctx *context.Context) {
web.NSOptions(rootpath, func(ctx *context.Context) {
f((*adtContext.Context)(ctx)) f((*adtContext.Context)(ctx))
}) })
return func(ns *Namespace) {
wo((*web.Namespace)(ns))
} }
} }
// NSPatch call Namespace Patch // NSPatch call Namespace Patch
func NSPatch(rootpath string, f FilterFunc) LinkNamespace { func NSPatch(rootpath string, f FilterFunc) LinkNamespace {
return func(ns *Namespace) { wn := web.NSPatch(rootpath, func(ctx *context.Context) {
web.NSPatch(rootpath, func(ctx *context.Context) {
f((*adtContext.Context)(ctx)) f((*adtContext.Context)(ctx))
}) })
return func(ns *Namespace) {
wn((*web.Namespace)(ns))
} }
} }
// 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 {
return func(ns *Namespace) {
nps := oldToNewLinkNs(params) nps := oldToNewLinkNs(params)
web.NSNamespace(prefix, nps...) wn := web.NSNamespace(prefix, nps...)
return func(ns *Namespace) {
wn((*web.Namespace)(ns))
} }
} }
// 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))
} }
} }