@Test public void supports() throws Exception { TestResponse response = createClient(Main::supports).path("/api/hw").get(); assertEquals(200, response.status().code()); assertEquals("Hello world!", response.asString().get()); response = createClient(Main::supports).path("/index.html").get(); assertEquals(200, response.status().code()); assertEquals(MediaType.TEXT_HTML.toString(), response.headers().first(Http.Header.CONTENT_TYPE).orElse(null)); response = createClient(Main::supports).path("/hello/Europe").get(); assertEquals(200, response.status().code()); assertEquals("{\"message\":\"Hello Europe\"}", response.asString().get()); }
public void supports() { Routing routing = Routing.builder() .register(StaticContentSupport.create("/static")) .get("/hello/{what}", (req, res) -> res.send(JSON.createObjectBuilder() .add("message", "Hello " + req.path() .param("what")) .build())) .register("/api", JerseySupport.builder() .register(HelloWorldResource.class) .build()) .build(); MediaContext mediaContext = MediaContext.builder() .addWriter(JsonpSupport.writer()) .build(); startServer(routing, mediaContext); }
Main { public void supports() { Routing routing = Routing.builder() .register(StaticContentSupport.create("/static")) .get("/hello/{what}", (req, res) -> res.send(JSON.createObjectBuilder() .add("message", "Hello " + req.path() .param("what")) .build())) .register("/api", JerseySupport.builder() .register(HelloWorldResource.class) .build()) .build(); MediaContext mediaContext = MediaContext.builder() .addWriter(JsonpSupport.writer()) .build(); startServer(routing, mediaContext); } }
Main { public void supports() { Routing routing = Routing.builder() .register(StaticContentSupport.create("/static")) .get("/hello/{what}", (req, res) -> res.send(JSON.createObjectBuilder() .add("message", "Hello " + req.path() .param("what")) .build())) .register("/api", JerseySupport.builder() .register(HelloWorldResource.class) .build()) .build(); MediaContext mediaContext = MediaContext.builder() .addWriter(JsonpSupport.writer()) .build(); startServer(routing, mediaContext); }  }
Main { public void supports() { Routing routing = Routing.builder() .register(StaticContentSupport.create("/static")) .get("/hello/{what}", (req, res) -> res.send(JSON.createObjectBuilder() .add("message", "Hello " + req.path() .param("what")) .build())) .register("/api", JerseySupport.builder() .register(HelloWorldResource.class) .build()) .build(); MediaContext mediaContext = MediaContext.builder() .addWriter(JsonpSupport.writer()) .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 supports() { Routing routing = Routing.builder() .register(StaticContentSupport.create("/static")) .get("/hello/{what}", (req, res) -> res.send(JSON.createObjectBuilder() .add("message", "Hello " + req.path() .param("what")) .build())) .register("/api", JerseySupport.builder() .register(HelloWorldResource.class) .build()) .build(); MediaContext mediaContext = MediaContext.builder() .addWriter(JsonpSupport.writer()) .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);  }