@Test public void mediaReader() throws Exception { TestResponse response = createClient(Main::mediaReader) .path("/create-record") .post(MediaPublisher.create(MediaType.parse("application/name"), "John Smith")); assertEquals(201, response.status().code()); assertEquals("John Smith", response.asString().get()); response = createClient(Main::mediaReader) .path("/create-record") .post(MediaPublisher.create(MediaType.TEXT_PLAIN, "John Smith")); assertEquals(500, response.status().code()); }
public void mediaReader() { Routing routing = Routing.builder() .post("/create-record", Handler.create(Name.class, (req, res, name) -> { System.out.println("Name: " + name); res.status(Http.Status.CREATED_201) .send(name.toString()); })) .build(); MediaContext mediaContext = MediaContext.builder() .addReader(NameReader.create()) .build(); startServer(routing, mediaContext); }
Main { public void mediaReader() { Routing routing = Routing.builder() .post("/create-record", Handler.create(Name.class, (req, res, name) -> { System.out.println("Name: " + name); res.status(Http.Status.CREATED_201) .send(name.toString()); })) .build(); MediaContext mediaContext = MediaContext.builder() .addReader(NameReader.create()) .build(); startServer(routing, mediaContext); } }
Main { public void mediaReader() { Routing routing = Routing.builder() .post("/create-record", Handler.create(Name.class, (req, res, name) -> { System.out.println("Name: " + name); res.status(Http.Status.CREATED_201) .send(name.toString()); })) .build(); MediaContext mediaContext = MediaContext.builder() .addReader(NameReader.create()) .build(); startServer(routing, mediaContext); }  }
Main { public void mediaReader() { Routing routing = Routing.builder() .post("/create-record", Handler.create(Name.class, (req, res, name) -> { System.out.println("Name: " + name); res.status(Http.Status.CREATED_201) .send(name.toString()); })) .build(); MediaContext mediaContext = MediaContext.builder() .addReader(NameReader.create()) .build(); startServer(routing, mediaContext); }  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 mediaReader() { Routing routing = Routing.builder() .post("/create-record", Handler.create(Name.class, (req, res, name) -> { System.out.println("Name: " + name); res.status(Http.Status.CREATED_201) .send(name.toString()); })) .build(); MediaContext mediaContext = MediaContext.builder() .addReader(NameReader.create()) .build(); startServer(routing, mediaContext); }  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);  }