@Test public void parametersAndHeaders() throws Exception { TestResponse response = createClient(Main::parametersAndHeaders).path("/context/aaa") .queryParameter("bar", "bbb") .header("foo", "ccc") .get(); assertEquals(200, response.status().code()); String s = response.asString().get(); assertTrue(s.contains("id: aaa")); assertTrue(s.contains("bar: bbb")); assertTrue(s.contains("foo: ccc")); }
public void parametersAndHeaders() { Routing routing = Routing.builder() .get("/context/{id}", (req, res) -> { StringBuilder sb = new StringBuilder(); req.headers() .first("foo") .ifPresent(v -> sb.append("foo: ").append(v).append("\n")); req.queryParams() .first("bar") .ifPresent(v -> sb.append("bar: ").append(v).append("\n")); sb.append("id: ").append(req.path().param("id")); res.headers().contentType(MediaType.TEXT_PLAIN); res.send(sb.toString()); }) .build(); startServer(routing); }
Main { public void parametersAndHeaders() { Routing routing = Routing.builder() .get("/context/{id}", (req, res) -> { StringBuilder sb = new StringBuilder(); req.headers() .first("foo") .ifPresent(v -> sb.append("foo: ").append(v).append("\n")); req.queryParams() .first("bar") .ifPresent(v -> sb.append("bar: ").append(v).append("\n")); sb.append("id: ").append(req.path().param("id")); res.headers().contentType(MediaType.TEXT_PLAIN); res.send(sb.toString()); }) .build(); startServer(routing); } }
Main { public void parametersAndHeaders() { Routing routing = Routing.builder() .get("/context/{id}", (req, res) -> { StringBuilder sb = new StringBuilder(); req.headers() .first("foo") .ifPresent(v -> sb.append("foo: ").append(v).append("\n")); req.queryParams() .first("bar") .ifPresent(v -> sb.append("bar: ").append(v).append("\n")); sb.append("id: ").append(req.path().param("id")); res.headers().contentType(MediaType.TEXT_PLAIN); res.send(sb.toString()); }) .build(); startServer(routing); }  }
Main { public void parametersAndHeaders() { Routing routing = Routing.builder() .get("/context/{id}", (req, res) -> { StringBuilder sb = new StringBuilder(); req.headers() .first("foo") .ifPresent(v -> sb.append("foo: ").append(v).append("\n")); req.queryParams() .first("bar") .ifPresent(v -> sb.append("bar: ").append(v).append("\n")); sb.append("id: ").append(req.path().param("id")); res.headers().contentType(MediaType.TEXT_PLAIN); res.send(sb.toString()); }) .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 parametersAndHeaders() { Routing routing = Routing.builder() .get("/context/{id}", (req, res) -> { StringBuilder sb = new StringBuilder(); req.headers() .first("foo") .ifPresent(v -> sb.append("foo: ").append(v).append("\n")); req.queryParams() .first("bar") .ifPresent(v -> sb.append("bar: ").append(v).append("\n")); sb.append("id: ").append(req.path().param("id")); res.headers().contentType(MediaType.TEXT_PLAIN); res.send(sb.toString()); }) .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);  }