Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.movingimage24.migration.verticle;
- import io.vertx.core.AbstractVerticle;
- import io.vertx.core.http.HttpServerResponse;
- import io.vertx.ext.web.Router;
- import io.vertx.ext.web.RoutingContext;
- import io.vertx.ext.web.handler.BodyHandler;
- public class HttpServerVerticle extends AbstractVerticle {
- @Override
- public void start() {
- Router router = Router.router(vertx);
- router.route().handler(BodyHandler.create());
- router.put("/putproducts").handler(this::putHandler);
- router.post("/postproducts").handler(this::postHandler);
- vertx.createHttpServer().requestHandler(router::accept).listen(8080);
- }
- //will work when route registers on PUT
- private void putHandler(RoutingContext routingContext) {
- System.err.println("PUT CALLED");
- HttpServerResponse response = routingContext.response();
- response.end();
- }
- //will NOT work when route registers on POST
- private void postHandler(RoutingContext routingContext) {
- System.err.println("POST CALLED");
- HttpServerResponse response = routingContext.response();
- response.end();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement