In this blog, I try to describe some basic routes of Akka-HTTP, redirection of the route and how to handle extra parameters that come in route.
so before writing the routes, you have to set the environment for it.
implicit val system = ActorSystem("my-system") implicit val materializer = ActorMaterializer() implicit val executionContext = system.dispatcher
These are the variables that are you need to define provisionally before writing the routes.
so now let’s writing the route –
val route = path("hello") { get { complete("Say hello to akka-http") } }
now you have to bind this route to a port
val bindingFuture = Http().bindAndHandle(route, "localhost", 8080)
Here we define simplest route “/hello” and whatever response you want to return you have to give into complete() method.
and we bind this route to the localhost:8080.
so let’s move another type of rote –
If you want to send some segment in the…
View original post 384 more words