@Test public void readContentEntity() throws Exception { TestResponse response = createClient(Main::readContentEntity).path("/foo") .post(MediaPublisher.create(MediaType.TEXT_PLAIN, "aaa")); assertEquals(200, response.status().code()); assertEquals("aaa", response.asString().get()); response = createClient(Main::readContentEntity).path("/bar") .post(MediaPublisher.create(MediaType.TEXT_PLAIN, "aaa")); assertEquals(200, response.status().code()); assertEquals("aaa", response.asString().get()); }
public void readContentEntity() { Routing routing = Routing.builder() .post("/foo", (req, res) -> { req.content() .as(String.class) .whenComplete((data, thr) -> { if (thr == null) { System.out.println("/foo DATA: " + data); res.send(data); } else { res.status(Http.Status.BAD_REQUEST_400); } }); }) .post("/bar", Handler.create(String.class, (req, res, data) -> { System.out.println("/foo DATA: " + data); res.send(data); })) .build(); startServer(routing); }
Main { public void readContentEntity() { Routing routing = Routing.builder() .post("/foo", (req, res) -> { req.content() .as(String.class) .whenComplete((data, thr) -> { if (thr == null) { System.out.println("/foo DATA: " + data); res.send(data); } else { res.status(Http.Status.BAD_REQUEST_400); } }); }) .post("/bar", Handler.create(String.class, (req, res, data) -> { System.out.println("/foo DATA: " + data); res.send(data); })) .build(); startServer(routing); } }
Main { public void readContentEntity() { Routing routing = Routing.builder() .post("/foo", (req, res) -> { req.content() .as(String.class) .whenComplete((data, thr) -> { if (thr == null) { System.out.println("/foo DATA: " + data); res.send(data); } else { res.status(Http.Status.BAD_REQUEST_400); } }); }) .post("/bar", Handler.create(String.class, (req, res, data) -> { System.out.println("/foo DATA: " + data); res.send(data); })) .build(); startServer(routing); }  }
Main { public void readContentEntity() { Routing routing = Routing.builder() .post("/foo", (req, res) -> { req.content() .as(String.class) .whenComplete((data, thr) -> { if (thr == null) { System.out.println("/foo DATA: " + data); res.send(data); } else { res.status(Http.Status.BAD_REQUEST_400); } }); }) .post("/bar", Handler.create(String.class, (req, res, data) -> { System.out.println("/foo DATA: " + data); res.send(data); })) .build(); startServer(routing); }  void firstRouting(); void routingAsFilter(); void parametersAndHeaders(); void advancedRouting(); void organiseCode(); void readContentEntity(); void mediaReader(); void supports(); void errorHandling(); void help(); void h(); static void main(String[] args); }
Main { public void readContentEntity() { Routing routing = Routing.builder() .post("/foo", (req, res) -> { req.content() .as(String.class) .whenComplete((data, thr) -> { if (thr == null) { System.out.println("/foo DATA: " + data); res.send(data); } else { res.status(Http.Status.BAD_REQUEST_400); } }); }) .post("/bar", Handler.create(String.class, (req, res, data) -> { System.out.println("/foo DATA: " + data); res.send(data); })) .build(); startServer(routing); }  void firstRouting(); void routingAsFilter(); void parametersAndHeaders(); void advancedRouting(); void organiseCode(); void readContentEntity(); void mediaReader(); void supports(); void errorHandling(); void help(); void h(); static void main(String[] args);  }