An open-source toolkit for building REST/HTTP-based integration layers on top of Scala and Akka. It's asynchronous, actor-based, fast, lightweight, modular and testable.
Questions tagged [spray-dsl]
43 questions
0
votes
1 answer
Global Filter Migration from Spray to Akka-Http 2
I have a filter of route handler using Spray Custom Directive0.
The purpose of this custom directive is to build a request filter to time the request processing time.
Inside the spray custom directive, I can use the RequestContext's function…

Alan
- 15
- 4
0
votes
2 answers
Spray : How to Unmarshal a response of JsArray or JsObject (ie JsValue) in pipeline
I am creating a service that aggregates data and will need to be able to read any unknown JSON document. I have the pipeline defined as follows:
private def pipeline = (
addHeader("Accept", "application/json")
~> sendReceive
~>…

Eric
- 127
- 7
0
votes
2 answers
Path parsing for ReST API in Spray
I have following code in Spray to parse the REST service called by user:
val route = {
pathPrefix("v0") {
pathPrefix("pets") {
pathEndOrSingleSlash {
pathEnd {
get {
complete("/v0/pets")
}
…

Chuchu
- 33
- 7
0
votes
1 answer
How do you Nest different Spray Directives into 1 directive
Let's say I have 1 directive for authentication. And after authentication, I would like to log. This is what I do so far:
get(...) {
myauthdirective() { v =>
myloggingdirective(v) {
...
}
}
}
So I would like to covert that to…

JWC
- 1,745
- 2
- 12
- 14
0
votes
1 answer
Multiple headers with the same name
Spray only supports extracting ONE header with a given name via headerValueByName. How could I get hold of ALL headers with the name "whatever" in the below Spray code snippet? There gotta be some way of extracting the headers!?
lazy val myRoute =…

aandeers
- 431
- 1
- 6
- 19
0
votes
2 answers
Is it possible to set Response Code from Marshaller in spray.io?
I have following code snippet where dataService returns Option[LocationDataResult].
I would like to set NotFound when dataService returns None and send the data back in case of Some( ...).
I have following code:
val route: Route = {
…

jaksky
- 3,305
- 4
- 35
- 68
0
votes
1 answer
Produce an error with scala and spray
I try to create simple CRUD application with scala and spray-routing. I have the following route:
override def receive = runRoute {
path("entities" / LongNumber) { id =>
get {
produce(instanceOf[MyEntity]) {
func => ctx…

pkozlov
- 746
- 5
- 17
0
votes
1 answer
java.lang.ClassCastException: Cannot cast akka.actor.Status$Success$ to akka.actor.Status$Success
I am facing a weird exception
java.lang.ClassCastException: Cannot cast akka.actor.Status$Success$ to akka.actor.Status$Success
at java.lang.Class.cast(Class.java:3094) ~[na:1.7.0_45]
at…

jaksky
- 3,305
- 4
- 35
- 68
0
votes
2 answers
Handle services returning Try values in Spray
I am working on a codebase where calling my Spray API need to synchronously call a service that returns a Try which Spray need to format and return over HTTP.
My initial attempt looked like this :
// Assume myService has a run method that returns a…

ahjmorton
- 965
- 1
- 5
- 18
0
votes
0 answers
spray authenticate directive returns different HTTP status codes
I am trying a basic authentication on post request in spray.io 1.3.2 using authenticate directive. My code looks following:
val route: Route = {
pathPrefix("ato") {
pathPrefix("v1") {
path("orders" / "updateStatus") {
…

jaksky
- 3,305
- 4
- 35
- 68
0
votes
1 answer
Hoes do Spray Parameters work?
I'm trying to wrap my head around how Spray has implemented their Directives, and in particular the Parameter extraction DSL.
I understand the magnet pattern (barely) but am stuck on how the ParamDefMagnet and ParamDefMagnet2 work together.
def…

Upio
- 1,364
- 1
- 12
- 27
0
votes
2 answers
spray-routing - akka ask with Marshaller
I am trying to complete a service in spray.io following examples from original documentation and I am stuck on error message:
could not find implicit value for parameter marshaller:…

jaksky
- 3,305
- 4
- 35
- 68
0
votes
1 answer
Routing directives are handled incorrectly despite not calling reject
Could you please explain why minor modification completely breaks my routing ?
My routing is quite simple
val myRoutes =
pathPrefix("MainService") {
post {
requestInstance {
request =>
XmlBody {
(command,…

expert
- 29,290
- 30
- 110
- 214