Questions tagged [spray-dsl]

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.

43 questions
9
votes
2 answers

How to structure a RESTful API with Spray.io?

When I'm using Spray.io to develop a RESTful API, how should I structure my application? I already saw this answer on how to split a Spray application, but I'm not satisfied with it, since it doesn't seem to use the "one actor per request" approach.…
Carlos Melo
  • 2,703
  • 3
  • 33
  • 44
7
votes
1 answer

How to unmarshal POST params and JSON body in a single route?

I have this route: val routes = pathPrefix("api") { path("ElevationService" / DoubleNumber / DoubleNumber) { (long, lat) => post { requestContext => println(long, lat) } } } This works…
Stefan Konno
  • 1,309
  • 2
  • 15
  • 28
7
votes
1 answer

Different routes based on request content type Spray Routing 1.2.1

I would like to support a couple of different content types submitted to the same URL: e.g: application/x-www-form-urlencoded, multipart/form-data, application/json I would like to do something like: post { …
5
votes
2 answers

why do I get "The requested resource could not be found." when accessing simple spray route?

I tried a simple spray example app and i cannot access the route, I uploaded the example source code which does not work to github: spray-tomcat-example: git clone https://github.com/avidanyum/spray-tomcat-example mvn package cp cp…
Jas
  • 12,534
  • 20
  • 79
  • 134
5
votes
1 answer

How can spray unmarshall a list in query parameters

I'm new to spray. Im playing around with building the routes, and while I manage to get parameters out of the query string using the parameters directive, I'm having trouble when I want one of the parameters to be a list. For this example I've…
user3911709
  • 171
  • 1
  • 6
5
votes
3 answers

Can I create a default OPTIONS method directive for all entry points in my route?

I don't want to explicitly write: options { ... } for each entry point / path in my Spray route. I'd like to write some generic code that will add OPTIONS support for all paths. It should look at the routes and extract supported methods from…
3
votes
1 answer

Spray rejections is not converted to status code?

I am following spray manual from here. So I put to gather pretty simple test class AtoImportServiceApiTest extends WordSpecLike with MustMatchers with ScalatestRouteTest { "AtoImportService" must { "return HTTP status 401 Unauhorized when…
jaksky
  • 3,073
  • 3
  • 31
  • 65
2
votes
1 answer

How to use string directive extractor in a nested route in Spray

Answering my own question here because this took me over a day to figure out and it was a really simple gotcha that I think others might run into. While working on a RESTful-esk service I'm creating using spray, I wanted to match routes that had an…
EdgeCaseBerg
  • 2,411
  • 1
  • 18
  • 37
2
votes
1 answer

Is akka-http fully compatible with spray-routing dsl?

Is akka-http fully compatible with spray-routing DSL? (my service is fully implemented in spray-routing trying to understand how seamless is migration (hopefully just dependency changing) Is it production ready? Can it run on tomcat like spray has…
Jas
  • 12,534
  • 20
  • 79
  • 134
2
votes
0 answers

How to add test-case of a route only with pathEnd

I have a route get { pathEnd { respondWithMediaType(`text/html`) { // XML is marshalled to `text/xml` by default, so we simply override here complete("[]") } } } I am trying to add a test-case for this route like this Get() ~>…
Ayush Mishra
  • 289
  • 4
  • 13
2
votes
1 answer

How do I write a path matcher that matches any part of the remaining path with a regex?

I'd like to write a path matcher that matches any of the remaining parts of the path with a regex, so for example, path("myregex".r) would match if i have remaining paths in the form: /myregex /foo/myregex /foo/myregex/bar /myregex/bar I looked…
Alex
  • 2,205
  • 1
  • 15
  • 29
2
votes
1 answer

Spray IO, add header to response

I have (formerly) REST spray.io webservice. Now, I need to generate SESSIONID in one of my methods to be used with some other methods. And I want it to be in the response header. Basically, I imagine logic like the following: path("/...") { get…
dmitry
  • 4,830
  • 4
  • 43
  • 68
2
votes
3 answers

is it possible to write a directive to match "any other query params"?

To ensure people don't append random query parameters (e.g. appending &r=234522.123 or similar) to avoid hitting our cache I want to have a way to reject any queries that are not handled explicitly. I can of course create one that contains a…
Stig Brautaset
  • 2,512
  • 1
  • 21
  • 37
2
votes
2 answers

Spray 1.2 ignores content-type header in response

I am trying to set application/json as content-Type in a spray-routing actor. But the content-type i see in my response always is text/plain. I tried using the spray-routing approach ("something") and the spray-can approacch ("something2") but the…
Gevatter Tod
  • 131
  • 4
2
votes
2 answers

Combine Query String Parameters with JSON Entity in Spray 1.2.0 Routing

Using Spray Routing, I would like have a single directive that merges the query string parameters with a JSON entity, with both being optional. I would want to have this happen before any marshalling happens. Something like this: val myRoute =…
1
2 3