Open aesteve opened 9 years ago
Allow users to compose their controllers with mixins so that they can reuse logic.
For example, they could declare a LoggingMixin this way :
LoggingMixin
@Mixin("log") public class LogMixin { @Before public void timeBefore(RoutingContext context) { context.put("timeBefore", System.currentTimeMillis()); context.next(); } @After public void logAfter(RoutingContext context) { long timeAfter = System.currentTimeMillis(); long timeBefore = Long.valueOf(context.get("timeBefore")); logger.info("time for request #0", timeAfter - timeBefore); context.next(); } }
Then in MyApiController :
MyApiController
@Controller("my/api") @Includes("log") public class MyApiController { @GET public void myApi(RoutingContext context, Payload<String> payload) { payload.set("Hello"); context.next(); } }
Allow users to compose their controllers with mixins so that they can reuse logic.
For example, they could declare a
LoggingMixin
this way :Then in
MyApiController
: