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

Spray.io: Can't compile test spec

I have the following service: trait PingService extends MyHttpService { val pingRoutes = path("ping") { get { complete("message" -> "pong") } } } MyHttpServiceis a custom class that extends HttpServiceand only contains…
Matteo Pacini
  • 17,507
  • 3
  • 58
  • 70
10
votes
1 answer

IDEA complains about Revolver.settings when trying to parse spray-template's build.sbt file

I've cloned the Spray template project (branch on_spray-can_1.1) as suggested on Spray's "Getting Started" page, and used sbt-idea to generate a corresponding IDEA project. It builds fine, but when I open my build.sbt file, the last line makes IDEA…
David Moles
  • 39,436
  • 24
  • 121
  • 210
10
votes
2 answers

Can I set a timeout and number of retries on a specific pipeline request?

When using spray's pipelining to make an HTTP request like this: val urlpipeline = sendReceive ~> unmarshal[String] urlpipeline { Get(url) } is there a way to specify a timeout for the request and the number of times it should retry for that…
Scott Smith
  • 103
  • 1
  • 6
10
votes
2 answers

Akka Actor Priorities

I have an actor-based system that performs periodic, cpu-intensive data ingests as well as serves RESTful endpoints. I'm using Akka actors to signal/control the various stages of the ingest process, and Spray (which is of course built on Akka) to…
Greg
  • 8,498
  • 15
  • 54
  • 85
10
votes
3 answers

spray-json and list marshalling

I'm using spray-json to marshal lists of custom objects into JSON. I have the following case class and its JsonProtocol. case class ElementResponse(name: String, symbol: String, code: String, pkwiu: String, remarks: String, priceNetto: BigDecimal,…
Marcin Cylke
  • 2,022
  • 2
  • 21
  • 38
10
votes
1 answer

SocketTimeoutException when I use Scalaj request

I'm trying to make a simple https request using this library https://github.com/scalaj/scalaj-http . The request contains some json data. Here is what I'm doing: val jsonHeaders = """{"jsonrpc": "2.0", "method": "someMethod", "params":…
Alan Coromano
  • 22,006
  • 44
  • 122
  • 184
10
votes
1 answer

Automating REST API documentation for routes

Is it possible to automate the documentation of routes in a Spray application? e.g. Is there perhaps an SBT plugin that generates markdown describing what it knows about the spray routes?
user2221884
  • 109
  • 3
9
votes
1 answer

How to get a reference to an existing ActorSystem in Akka?

is it possible in Akka (scala) to get a reference to an existing ActorSystem? I am working on a Spray application with another Actor for DB. I am also extending Directives to have an object per path. the directives are not actors by themselves, but…
Ehud Kaldor
  • 706
  • 1
  • 6
  • 19
9
votes
1 answer

Extracting Raw JSON as String inside a Spray POST route

I've a POST Spray route and the request contains a JSON body (content-type "application/json"). I want a way to extract the raw JSON from this request inside my route. For http://host:port/somepath/value1 I want to extract the post body as…
Soumya Simanta
  • 10,777
  • 23
  • 95
  • 153
9
votes
2 answers

Forwarding HTTP/REST Request to another REST server in Spray

I've a bunch of existing REST services (#1 and #2 below) that are running on different endpoints that are used internally only. Now I want to expose some of these REST APIs (API-1 and API-2) externally using Spray because this external endpoint will…
Soumya Simanta
  • 10,777
  • 23
  • 95
  • 153
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
9
votes
1 answer

spray Marshaller for futures not in implicit scope after upgrading to spray 1.2

After updating to spray 1.2 I got a problem regarding my JSON-Marshallers that worked perfectly with 1.1. Doing the following inside a HttpService trait TestHttpService extends HttpService with SprayJsonSupport with DefaultJsonProtocol{ self :…
jens
  • 443
  • 2
  • 12
9
votes
4 answers

How do i specify spray Content-Type response header?

I understand that spray does that for me, but I still want to override it with my header, how can I override the header in the response? My response looks like this: case HttpRequest(GET, Uri.Path("/something"), _, _, _) => sender !…
Jas
  • 12,534
  • 20
  • 79
  • 134
9
votes
1 answer

Convert polymorphic case classes to json and back

I am trying to use spray-json in scala to recognize the choice between Ec2Provider and OpenstackProvider when converting to Json and back. I would like to be able to give choices in "Provider", and if those choices don't fit the ones available then…
wernerb
  • 105
  • 1
  • 5
8
votes
1 answer

Issue with akka application inside docker container

We have a akka application running in production in a non clustered mode ( doesn't akka clustering ). We are trying to dockerize this application and running into an issue. We are using docker host networking and for various other reasons we are…
Phani
  • 1,404
  • 2
  • 12
  • 17
1 2
3
63 64