Advertisement
Guest User

FLOW_AKKA_

a guest
Nov 13th, 2019
309
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.33 KB | None | 0 0
  1. final Flow<HttpRequest, HttpResponse, NotUsed> routeFlow = Flow.of(HttpRequest.class).map(
  2.                 req -> {
  3.                     if(req.method() == HttpMethods.GET) {
  4.                         if (req.getUri().path().equals("/")) {
  5.                             return HttpResponse.create().withEntity(ContentTypes.TEXT_HTML_UTF8, ByteString.fromString("<html><body>Hello world!</body></html>"));
  6.  
  7.                         }
  8.                         if (req.getUri().path().equals("/test")) {
  9.                             return HttpResponse.create().withEntity(ByteString.fromString("TEST WORKS!"));
  10.                         } else {
  11.                             req.discardEntityBytes(materializer);
  12.                             return HttpResponse.create().withStatus(StatusCodes.NOT_FOUND).withEntity("NOPE");
  13.                         }
  14.                     }else{
  15.                         if (req.getUri().path().equals("/")){
  16.                             return HttpResponse.create().withEntity(ByteString.fromString("IT'S THE POST DUDE"));
  17.                         }
  18.                         else {
  19.                             req.discardEntityBytes(materializer);
  20.                             return HttpResponse.create().withStatus(StatusCodes.NOT_FOUND).withEntity("NOPE");
  21.                         }
  22.                     }
  23.                 });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement