Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- final Flow<HttpRequest, HttpResponse, NotUsed> routeFlow = Flow.of(HttpRequest.class).map(
- req -> {
- if(req.method() == HttpMethods.GET) {
- if (req.getUri().path().equals("/")) {
- return HttpResponse.create().withEntity(ContentTypes.TEXT_HTML_UTF8, ByteString.fromString("<html><body>Hello world!</body></html>"));
- }
- if (req.getUri().path().equals("/test")) {
- return HttpResponse.create().withEntity(ByteString.fromString("TEST WORKS!"));
- } else {
- req.discardEntityBytes(materializer);
- return HttpResponse.create().withStatus(StatusCodes.NOT_FOUND).withEntity("NOPE");
- }
- }else{
- if (req.getUri().path().equals("/")){
- return HttpResponse.create().withEntity(ByteString.fromString("IT'S THE POST DUDE"));
- }
- else {
- req.discardEntityBytes(materializer);
- return HttpResponse.create().withStatus(StatusCodes.NOT_FOUND).withEntity("NOPE");
- }
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement