Questions tagged [spray]

spray is an open-source toolkit for building REST/HTTP-based integration layers on top of Scala and Akka.

spray is an open-source toolkit for building REST/HTTP-based integration layers on top of Scala and Akka. It sports the following main features:

  • Completely asynchronous, non-blocking, actor-based request processing for efficiently handling very high numbers of concurrent connections

  • Powerful, flexible and extensible internal Scala DSL for declaratively defining your web service behavior

  • Immutable model of the HTTP protocol, decoupled from the underlying web server / servlet container

  • Full testability of your REST services, without the need to fire up containers or actors

Documentation for spray is available at the spray website.

The spray user group has active discussions on using this software.

957 questions
16
votes
2 answers

Spray routing 404 response

I have a service which returns an Option[ProductDoc] in a Future (as an akka ask) How do I respond in spray routing so that a valid product repsonds with a product but an unknown but well formed one returns a 404? I want the code to fill in the gap…
deanWombourne
  • 37,003
  • 13
  • 93
  • 99
15
votes
2 answers

How to mock spray-client response

I have a simple spray client : val pipeline = sendReceive ~> unmarshal[GoogleApiResult[Elevation]] val responseFuture = pipeline {Get("http://maps.googleapis.com/maps/api/elevation/jsonlocations=27.988056,86.925278&sensor=false") } responseFuture…
Eleni
  • 645
  • 6
  • 19
14
votes
1 answer

Execution Context and Dispatcher - Best practices, useful configurations and Documentation

Scala Execution Context and Dispatchers - Listing and comparison: Why ? There are a lot of questions around what/how/what is the best Execution Context to use to execute futures on in Scala and how to configure the dispatcher. Still I never was able…
Andreas Neumann
  • 10,263
  • 1
  • 29
  • 52
14
votes
2 answers

Twirl templates cannot be seen in the code (spray application)

I have some configuration problem I can't see. I've followed the instructions provided in the latest twirl README, but the html package is undefined according to the compiler. I've included the sbt-twirl plugin in the project/plugins.sbt…
Rajish
  • 6,525
  • 3
  • 31
  • 49
14
votes
1 answer

How can I parse out get request parameters in spray-routing?

This is what the section of code looks like get{ respondWithMediaType(MediaTypes.`application/json`){ entity(as[HttpRequest]){ obj => complete{ println(obj) "ok" } …
Kevin Colin
  • 297
  • 2
  • 4
  • 10
13
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
  • 41,137
  • 49
  • 170
  • 286
13
votes
2 answers

Akka.NET actor system in ASP.NET

I created a service with a RESTful API in ASP.NET, hosted in IIS. Inside this service, I would like to create an actor system with Akka.NET. Upon creating the actor system: var actorSystem = ActorSystem.Create("myActorSystem"); The following…
Odsh
  • 655
  • 5
  • 19
13
votes
2 answers

spray-json error: could not find implicit value for parameter um

I have this case class case class Person(val name: String) object JsonImplicits extends DefaultJsonProtocol { implicit val impPerson = jsonFormat1(Person) } I'm trying spray-json in order to parse post request: post { entity(as[Person]) {…
Jas
  • 12,534
  • 20
  • 79
  • 134
13
votes
2 answers

Deploying, starting and stopping Scala applications on a remote server

What the preferred way is to deploy Scala applications on a remote Linux server. This is a fairly simple, but limited, way of deploying a Scala app on a remote server (nice for quick testing of not-so-sensitive projects): From the remote server I…
Jack
  • 15,582
  • 17
  • 86
  • 162
12
votes
3 answers

Get form parameters from a post request using spray/scala

I'm really new with all this Scala/Spray. With some testing I was able to get parameters from a Get request using the parameters function. However I'm trying to fetch some parameters sent from a POST request on the body of the request. It seems like…
Mike
  • 465
  • 1
  • 4
  • 12
12
votes
1 answer

Scala testing mocking implicit parameters?

I'm having a bit of a tough time trying to understand how to write tests in Scala when implicit parameters are involved. I have the following (short version) of my code and test: Implementation (Scala 2.10, Spray and Akka): import…
C0deAttack
  • 23,507
  • 18
  • 68
  • 79
11
votes
1 answer

How to expose REST service for JSON?

I need to expose a Spray service that accepts JSON payload. Where can I find a sample that would demonstrate such a feature?
Giri
  • 240
  • 3
  • 12
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
  • 16,021
  • 13
  • 78
  • 152
10
votes
3 answers

Request was neither completed nor rejected within 1 second Scala Spray Testing

I currently testing a web service, and I keep on running into an error where the web service test is failing because it is timing out. I'm trying to extends that timeout to be 5 seconds long. I'm trying to mimic a solution that some one posted on…
Chris Stewart
  • 1,554
  • 1
  • 27
  • 58
10
votes
1 answer

Resolving Akka futures from ask in the event of a failure

I am calling an Actor using the ask pattern within a Spray application, and returning the result as the HTTP response. I map failures from the actor to a custom error code. val authActor =…
James Tidman
  • 173
  • 1
  • 9
1
2
3
63 64