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
12
votes
3 answers

Idiomatic way to create a basic HTTP Post request with Akka HTTP

I'm trying to figure out how to create a basic HTTP POST request with the Akka HTTP library. This is what I came up with: val formData = Await.result(Marshal(FormData(combinedParams)).to[RequestEntity], Duration.Inf) val r = HttpRequest(POST, url,…
Frank Versnel
  • 373
  • 1
  • 4
  • 9
11
votes
1 answer

akka-stream + akka-http lifecycle

TLDR: is it better to materialize a stream per request (i.e. use short-lived streams) or to use a single stream materialization across requests, when I have an outgoing http request as a part of the stream? Details: I have a typical service that…
Tim
  • 2,008
  • 16
  • 22
11
votes
1 answer

How to use Akka-HTTP client websocket send message

I'm trying client-side websocket by following doc at webSocketClientFlow. sample code is: import akka.actor.ActorSystem import akka.Done import akka.http.scaladsl.Http import akka.stream.ActorMaterializer import akka.stream.scaladsl._ import…
xring
  • 727
  • 2
  • 8
  • 29
11
votes
2 answers

How to Marshall a Future[Option[Foo]] class to JSON in AKKA-HTTP

Im new to acala and akka, so the question may be a little silly. I have a class: case class Foo(colUNO: String, colDOS: Long) I have a funtion: getById() : Future[Option[Foo]] And I am trying to use it in the akka-http route def main(args:…
George C
  • 1,168
  • 13
  • 30
10
votes
1 answer

Shut down Akka HTTP app

I have a running Akka HTTP application and I want to shut it down. Pressing Ctrl + C in SBT does not work for me (my shell is currently Git Bash for Windows). What's the recommended way of shutting down an Akka app gracefully?
Matthias Braun
  • 32,039
  • 22
  • 142
  • 171
10
votes
1 answer

How to match all paths in Akka HTTP

Most Akka HTTP examples show it is really easy to define Routes using path. I have the following (slightly simplified) from the introductory example, val route = path("hello") { complete( HttpEntity( …
vossad01
  • 11,552
  • 8
  • 56
  • 109
10
votes
2 answers

akka-http: complete request with flow

Assume I have set up an arbitrarily complex Flow[HttpRequest, HttpResponse, Unit]. I can already use said flow to handle incoming requests with Http().bindAndHandle(flow, "0.0.0.0", 8080) Now I would like to add logging, leveraging some existing…
Stefano Bonetti
  • 8,973
  • 1
  • 25
  • 44
10
votes
2 answers

Authentication with Akka-Http

We're developing an iOS app, where the user needs to authenticate using email+password (or mobile number). Our backend is made of a couple of microservices using Akka-Http. It needs to be fast, scalable, concurrent, and the…
10
votes
3 answers

Akka HTTP Streaming JSON Deserialization

Is it possible to dynamically deserialize an external, of unknown length, ByteString stream from Akka HTTP into domain objects? Context I call an infinitely long HTTP endpoint that outputs a JSON Array that keeps growing: [ { "prop": true,…
Martijn
  • 2,268
  • 3
  • 25
  • 51
10
votes
1 answer

akka-http: How to set response headers

I've a route as follows: val route = { logRequestResult("user-service") { pathPrefix("user") { get { respondWithHeader(RawHeader("Content-Type", "application/json")) { parameters("firstName".?,…
Abhijit Sarkar
  • 21,927
  • 20
  • 110
  • 219
9
votes
1 answer

reference.conf vs application.conf files in Akka

I am new in Akka and I am trying to understand the difference between the reference.conf and application.conf files? What is the proper way to use them? What kind of variables should I have in each file?
pik4
  • 1,283
  • 3
  • 21
  • 56
9
votes
0 answers

Akka HTTP: the requested resource could not be found

I'm using the Akka HTTP "Minimal Example" for my first steps in Akka HTTP. private Route createRoute() { return route( path("hello", () -> get(() -> complete("

Say hello to akka-http

")))); } Now I want to add a route to…
Thane
  • 91
  • 3
9
votes
1 answer

Akka HTTP api routes structure

I'm writing Akka-HTTP based REST API. As I'm new to Akka and Scala, I'm not sure what could be the best way of organize code in my project. I will have approx. 7 different entities with basic CRUD. Which means I will have over 25 routes in the API.…
RB_
  • 1,195
  • 15
  • 35
9
votes
2 answers

How to enable websockets on AWS Cloudfront

I have an Akka HTTP server running on AWS EC2 Autoscale cluster. This EC2 auto scale cluster has an ELB Application Load balancer in front. In addition to the ELB, we have a cloud front distribution that is set to serve static files. We're facing…
9
votes
1 answer

akka http compile error

I am new in akka framework and now try to setup simple webservice with this framework . write a simple akka-http application : import akka.actor.ActorSystem import akka.http.scaladsl.Http import akka.http.scaladsl.server.Directives._ import…
mah454
  • 1,571
  • 15
  • 38