The middleware must have below methods:
interfaceBpframeworkMiddleware{/** name of middleware */name: string,/** web framework type. e.g. 'koa' **/type: string,/** initiator the middleware */initiator: (app:any,bpApp:any)=>void,/** The framework context finished, all objects of framework, e.g. FeignClient, start working. */contextFinished?: (app:any,bpApp:any)=>void,/** call before route */beforeRoute?: (app:any,bpApp:any,request?:any)=>Promise<boolean>,/** call after route */afterRoute?: (app:any,bpApp:any)=>Promise<boolean>,}initiator -> contextFinished -> beforeRoute -> afterRoute
Example:
exportdefault{name: 'test-middleware',type: 'koa',initiator(app,bpApp){},asyncbeforeRoute(ctx,bpApp,request): boolean{// To interrupt process of follow-up .returnfalse;},asyncafterRoute(ctx,bpApp): boolean{// To interrupt process of follow-up.returnfalse;},}