Closed vietj closed 9 years ago
do you have some time to review this @purplefox ?
Could you explain this a bit, and the fix?
currently we have usage of interfaces that extends Handler in Apex and we do use those sub interfaces as handle arguments.
In JS method arguments, such handlers are expected to be function type. Such handler subtypes are objects that provide an "handle" method.
This patch allows to use them directly as handlers (which is what is done in Java or Groovy) instead of referencing the handle method. Handlers are either function (like before) or objects that are subtypes of the io.vertx.core.Handler interface.
Can't the user simply do:
router.route(handler.handle);
?
they can, however it helps the codetrans project to create correct JS code from Java code when creating such handlers in examples and doc.
for instance in Apex we do have examples like:
router.route().handler(CookieHandler.create());
router.route().handler(SessionHandler.create(LocalSessionStore.create(vertx)));
AuthService authService = AuthService.createEventBusProxy(vertx, "acme.authservice");
AuthHandler redirectAuthHandler = RedirectAuthHandler.create(authService);
// All requests to paths starting with '/private/' will be protected
router.route("/private/").handler(redirectAuthHandler);
// Handle the actual login
router.route("/login").handler(FormLoginHandler.create(authService));
// Set a static server to serve static resources, e.g. the login page
router.route().handler(StaticHandler.create());
it should be rewritten:
router.route().handler(CookieHandler.create()::handle);
router.route().handler(SessionHandler.create(LocalSessionStore.create(vertx))::handle);
AuthService authService = AuthService.createEventBusProxy(vertx, "acme.authservice");
AuthHandler redirectAuthHandler = RedirectAuthHandler.create(authService);
// All requests to paths starting with '/private/' will be protected
router.route("/private/").handler(redirectAuthHandler::handle);
// Handle the actual login
router.route("/login").handler(FormLoginHandler.create(authService)::handle);
// Set a static server to serve static resources, e.g. the login page
router.route().handler(StaticHandler.create()::handle);
Need to think about this some more ;)
ok :-) , I will try in Codetrans to rewrite handler argument to "handler.handle" meanwhile.
I've handled in in the codetrans project
@purplefox please review