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
15
votes
1 answer

How to do authentication using Akka HTTP

Looking for a good explanation on how to do authentication using akka HTTP. Given a route that looks like val route = path("account") { authenticateBasic(realm = "some realm", myAuthenticator) { user => get { …
mattmar10
  • 515
  • 1
  • 4
  • 16
15
votes
1 answer

How can I use a Future inside an Akka HTTP Directive?

I currently have a directive that I'm using to secure resources in an Akka HTTP app, like so: def authenticate: Directive1[Login] = optionalHeaderValueByName("Authorization") flatMap { val accessToken = authz.split(' ').last case…
Ian Phillips
  • 567
  • 4
  • 13
14
votes
4 answers

Functions / methods in Scala. How does this work?

I am new to Scala and have a hard time understanding all the ways of declaring and using functions. Can someone please explain, step by step, what is going on here? I am following a course that introduces Akka HTTP. The code works, but I do not…
Kristoffer
  • 151
  • 9
14
votes
3 answers

How to add a custom marshaller to akka http?

As a beginner to both scala and akka-http, I am trying to hook into the serialization aka marshalling process. The project uses akka@2.5.2 and akka-http@10.0.10". Furthermore, it has the akka-http-spray-json dependency included. In the codebase, we…
k0pernikus
  • 60,309
  • 67
  • 216
  • 347
14
votes
3 answers

How to read query parameters in akka-http?

I know akka-http libraries marshal and unmarshal to class type while processing request.But now, I need to read request-parameters of GET request. I tried parameter() method and It is returning ParamDefAux type but i need those values as strings…
Siva Kumar
  • 632
  • 3
  • 9
  • 19
14
votes
1 answer

akka-http with multiple route configurations

Quick Background I am running through some examples learning the Akka HTTP stack for creating a new REST project (completely non-UI). I have been using and augmenting the Akka HTTP Microservice Example to work through a bunch of use cases and…
el n00b
  • 1,957
  • 7
  • 37
  • 64
14
votes
2 answers

Conditionally skip flow using akka streams

I'm using akka streams and I have a segment of my graph that I need to conditionally skip because the flow can't handle certain values. Specifically, I have a flow that takes a string and makes http requests, but the server can't handle the case…
Falmarri
  • 47,727
  • 41
  • 151
  • 191
13
votes
1 answer

Circe - Use default fields in case class when decoding/encoding json

Lets say I have this case class: case class Foo(bar: String, baz: Boolean = false) which is used in when decoding/encoding API requests/responses using akka-http-json in an example similar to this: import akka.actor.ActorSystem import…
simen-andresen
  • 2,217
  • 4
  • 25
  • 39
13
votes
2 answers

File upload using Akka HTTP

I am trying to implement file upload functionality in my application using Akka HTTP. I am using akka-stream version 2.4.4. Here is the code (modified from akka-doc) path("fileupload") { post { extractRequestContext { ctx => { …
Yadu Krishnan
  • 3,492
  • 5
  • 41
  • 80
13
votes
1 answer

Get http headers with akka routing dsl

I'm new to Scala, and this problem frustrates me. How can I get all headers from request? val route = { path("lol") { //get httpHeaders complete(HttpResponse()) } }
npmrtsv
  • 434
  • 6
  • 22
13
votes
2 answers

akka http throws EntityStreamException: Entity stream truncation

I'm writing a client for a rest API using the akka http library. The library seems very powerful, but it works very unstable for me. Quite often (not always) it throws the following exception when I try to consume an…
13
votes
1 answer

How to unmarshall akka http request entity as string?

I'm trying to unmarshall request payload as string, but for some reason it's failing. My code: path("mypath") { post { decodeRequest { entity(as[String]) {jsonStr => //could not find implicit value for...FromRequestUnmarshaller[String] …
User
  • 31,811
  • 40
  • 131
  • 232
12
votes
1 answer

How can I use http request headers for content negotiation in a Mashaller?

My app supports protobuf and JSON serialzation. For JSON serialization I use com.trueaccord.scalapb.json.JsonFormat, my dtos are generated from proto definitions. The com.trueaccord serializer wraps option types to JSON objects which is causing…
Jeno Laszlo
  • 2,023
  • 18
  • 36
12
votes
2 answers

Akka Http Client :Custom headers

I am trying to use Akka-Http for invoking REST url. I am following this example from the akka documentation. Using this I am able to make the rest call. But I am not able to find out how to add custom request headers. I tried using…
Yadu Krishnan
  • 3,492
  • 5
  • 41
  • 80
12
votes
2 answers

How to download a HTTP resource to a file with Akka Streams and HTTP?

Over the past few days I have been trying to figure out the best way to download a HTTP resource to a file using Akka Streams and HTTP. Initially I started with the Future-Based Variant and that looked something like this: def…
steinybot
  • 5,491
  • 6
  • 37
  • 55