Questions tagged [akka-http]

The purpose of the Akka HTTP layer is to expose Actors to the web via HTTP and to enable them to consume HTTP services as a client. It is not an HTTP framework, it is an Actor-based toolkit for interacting with web services and clients.

The purpose of the Akka HTTP layer is to expose Actors to the web via HTTP and to enable them to consume HTTP services as a client. It is not an HTTP framework, it is an Actor-based toolkit for interacting with web services and clients.

More Info:

1489 questions
3
votes
2 answers

How to wrap an REST API client in an Actor

I'm trying to write an actor that calls an HTTP REST API. The rest API needs a query parameter that will be passed from the invoking Actor. The official documentation has an example to achieve the above using a preStart method that pipes the message…
MojoJojo
  • 3,897
  • 4
  • 28
  • 54
3
votes
2 answers

Possible to offload route completion DSL to actors in akka-http?

I have become interested in the akka-http implementation but one thing that strikes me as kind of an anti-pattern is the creation of a DSL for all routing, parsing of parameters, error handling and so on. The examples given in the documents are…
Robert Simmons Jr.
  • 1,182
  • 8
  • 21
3
votes
1 answer

How to define a JSON format for an object with nested generic types?

I have a case class with this definition: case class EndpointResponse[A](timestamp: Instant, uuid: UUID, content: A) and case class User(id: UUID, username: String, email: String) And a JsonFormat with the following definition: trait…
Robert Simmons Jr.
  • 1,182
  • 8
  • 21
3
votes
1 answer

Treat index.html as default file in Akka HTTP's getFromDirectory

Assuming I have a folder foo with an index.html file in it and the following minimal (but most likely not functional) server code for Akka HTTP below: object Server extends App { val route: Route = pathPrefix("foo") { …
astorije
  • 2,666
  • 2
  • 27
  • 39
3
votes
1 answer

How to get akka.http.scaladsl.model.HttpRequest body?

I am using akka-http and writing an Unmarhsaller for one of my classes. What I am trying to do is to get the body of the POST request as a String so I can create my object with it : case class MyClass(geom: String) implicit def…
meucaa
  • 1,455
  • 2
  • 13
  • 27
3
votes
1 answer

Circuit breaker on http client can't close back after failure

An example of circuit breaker over akka http client that looks totally simple doesn't work expected for me. object HttpWithCircuitBreaker extends App { implicit val system = ActorSystem() implicit val materializer = ActorMaterializer() …
kharole
  • 133
  • 7
3
votes
1 answer

Akka HTTP Connection Pool Hangs After Couple of Hours

I have an HTTP Connection Pool that hangs after a couple of hours of running: private def createHttpPool(host: String): SourceQueue[(HttpRequest, Promise[HttpResponse])] = { val pool =…
pradyuman
  • 1,089
  • 2
  • 14
  • 20
3
votes
1 answer

akka http custom nested directives

I'm trying to nest existing akka http (version 10) directives to create my own custom directives. I'm having issues with things like this: def echoHeaderDirective: Directive0 = optionalHeaderValueByName("X-Echo-Header") { case Some(value) =>…
kag0
  • 5,624
  • 7
  • 34
  • 67
3
votes
1 answer

How to run Akka Streams graph on a separate dispatcher with timeout?

This question is based on a pet project that I did and this SO thread. Inside a Akka HTTP route definition, I start a long-running process, and naturally I want to do that without blocking the user. I'm able to achieve this with the code snippet…
Abhijit Sarkar
  • 21,927
  • 20
  • 110
  • 219
3
votes
0 answers

How to generate swagger document for akka http web socket route?

How to generate swagger document for akka http web socket route ? I have able to write akka Http get,put,post,delete. for example @Path("/postPing") @ApiOperation(value = "Find a ping", notes = "Returns a pong", httpMethod = "POST",response =…
Dhirendra
  • 289
  • 3
  • 8
3
votes
2 answers

How to send a response code as a response in Akka Http?

I have the below code: val route:Route={ path("hello"){ get{ complete{ "done" } } } } Http().bindAndHandle(route, "localhost", 8187) Here the complete responds back with string "done". However, I…
codingsplash
  • 4,785
  • 12
  • 51
  • 90
3
votes
0 answers

How to organize complex spray / akka http routes?

Does anyone know any good rules of thumb, or good articles about organizing complex routes? My Service has a routing that spans over about 400 lines, and IntelliJ is not the only one that has problems parsing and navigating it (also me). What is a…
Ákos Vandra-Meyer
  • 1,890
  • 1
  • 23
  • 40
3
votes
1 answer

How to run an Akka-HTTP server inside an Akka cluster?

I am building an Akka cluster and want to use Akka-HTTP server as an API server inside. How does one do that? I would imagine it will be a cluster singleton, as it is an access point to the cluster, but making it an actor seems weird, as it will…
Ehud Kaldor
  • 753
  • 1
  • 7
  • 20
3
votes
2 answers

How to match path segments in URI with Akka-http low-level API

I'm trying to implement a REST API using the akka-http low-level API. I need to match a request for paths containing resource ids, for instance, "/users/12", where the 12 is the id of the user. I'm looking for something along these lines: case…
nsantos
  • 568
  • 1
  • 5
  • 15
3
votes
1 answer

scala akka http route with authenticate by a token

i m trying to convert my spray routes in akka http. It s really complicated for a novice but i almost do everything. I m bloked by the authentication. Indeed, i have a route with a get param token=???? How can i check this token with akka? My route…
thomas poidevin
  • 176
  • 2
  • 20