-1

I'm trying to work with akka Http with Java.

I would like to load a route that look like this : hello/world

On my HttpApp, I tried:

return route(
                path("hello/world", () ->
                        get(() ->
                                complete("<h1>Say hello to akka-http</h1>")
                        )
                );
Joe
  • 4,877
  • 5
  • 30
  • 51
Federico Saenz
  • 512
  • 1
  • 6
  • 21

1 Answers1

0

Try the following, as per the docs.

import static akka.http.javadsl.server.PathMatchers.*;

return route(
  path(segment("hello").slash(segment("world")), () ->
    get(() ->
     complete("<h1>Say hello to akka-http</h1>")
    )
);
Stefano Bonetti
  • 8,973
  • 1
  • 25
  • 44
  • I try it, but doesn't works. I got the following errors: - Cannot resolve method segment(java.lang.String) - Cannot resolve method slash(java.lang.String) In facts, Intellij IDEA autocomplete doens't works with segment or slash functions. – Federico Saenz Jan 17 '17 at 19:10
  • You're probably missing an import. I have added it to the answer. – Stefano Bonetti Jan 17 '17 at 20:20