egg-tiaozhan-controller-extension
Tiaozhan Controller Extension
-
Get current route from
ctx.currentRoute
.ctx.currentRoute.Controller
for the target Controller class andctx.currentRoute.methodName
for the target method name. -
Return response by
return
.
Install
$ npm i egg-tiaozhan-controller-extension --save
Usage
// {app_root}/config/plugin.jsexportstiaozhanControllerExtension = enable: true package: 'egg-tiaozhan-controller-extension';
Configuration
// {app_root}/config/config.default.jsexportstiaozhanControllerExtension = ;
No Configuration.
Example
Get Current Route
{ // 也可以在中间件等环境使用 const route = thisctxcurrentRoute; // route.Controller === HomeController // route.Controller.prototype === HomeController.prototype // route.methodName === 'helloEgg' }
Use Reflect
{ // some code } // Need reflect-metadataReflect;
Use return to response
{ return 'hi, egg'; } { return message: 'hi, egg' ; }
Questions & Suggestions
Please open a PR.