New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added multiple handlers support inside route object #652

Merged
merged 2 commits into from Jul 5, 2017

Conversation

3 participants
@slinkydeveloper
Copy link
Member

slinkydeveloper commented Jun 26, 2017

Following this google groups post, I implemented the multiple handlers support:

router.get("/path").handler(routingContext -> {
      routingContext.put("response", "handler1");
      routingContext.next();
    }).handler(routingContext -> {
      routingContext.put("response", routingContext.get("response") + "handler2");
      routingContext.next();
    }).handler(routingContext -> {
      HttpServerResponse response = routingContext.response();
      response.setChunked(true);
      response.end(routingContext.get("response") + "handler3");
    });

There is only one downside. In the code above, you will use the same Route object, while in the code below you create 3 different Route objects:

router.get("/path").handler(routingContext -> {
      routingContext.put("response", "handler1");
      routingContext.next();
    });
router.get("/path").handler(routingContext -> {
      routingContext.put("response", routingContext.get("response") + "handler2");
      routingContext.next();
    });
router.get("/path").handler(routingContext -> {
      HttpServerResponse response = routingContext.response();
      response.setChunked(true);
      response.end(routingContext.get("response") + "handler3");
    });

However both this cases are handled (see the unit tests added)

@vietj vietj added the to review label Jun 26, 2017

@pmlopes pmlopes self-requested a review Jul 3, 2017

@pmlopes

pmlopes approved these changes Jul 3, 2017

@pmlopes pmlopes merged commit a98c4cf into vert-x3:master Jul 5, 2017

@pmlopes pmlopes removed the to review label Jul 5, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment