Menu
  • HOME
  • TAGS

Spray rejections is not converted to status code?

scala,spray,spray-dsl

You need to "seal the route" to see actual status codes. Sealing the route means that the default rejection and exception handlers are used to handle any so far unhandled rejections and exceptions. This automatically done when using runRoute in your service but it isn't done automatically in the testkit...

spray-routing - akka ask with Marshaller

scala,akka,spray,spray-dsl

I think you need an implicit ExecutionContext in scope, to provide the Future marshalling ability.

java.lang.ClassCastException: Cannot cast akka.actor.Status$Success$ to akka.actor.Status$Success

akka,spray,spray-dsl

sender() ! akka.actor.Status.Success akka.actor.status.Success is a case class requiring one argument. Looks like that you've replied not with a class instance, but with a partially-applied Success.apply(_) function, which is not you've planned to do, I believe: case Success(_) => sender() ! akka.actor.Status.Success(storeId) ...

Spray Routing not matching HTTP Method correctly

akka,spray,http-method,spray-dsl

No, your code is (almost) correct. The issue is that, in spray, the code that lives in a method matcher but does not live under an extraction (one of the directives "extracting" something, such as "parameters" or "segment") is executed all times. In your case, you correctly match the path...

Handle services returning Try values in Spray

scala,try-catch,spray,spray-dsl

The way I solved this was do do the following : lazy val myService = new Service() val routes = path("api") { get { complete { handleTry { myService.run() } } } } ~ path("api" / LongNumber) { (num: Long) => get { complete { handleTry { myService.run(num) } }...

Produce an error with scala and spray

scala,spray,spray-json,spray-dsl

You have the RequestContext (ctx) so you can call reject, failWith or any other methods available on the RequestContext. val route = path("entities" / LongNumber) { id => get { produce(instanceOf[MyEntity]) { func => ctx => heavyLookupById(id, func, ctx) } } } def heavyLookupById(id: Long, func: MyEntity => Unit, ctx:...

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

scala,spray,spray-json,spray-dsl

You can just nest the directives: path("ElevationService" / DoubleNumber / DoubleNumber) { (long, lat) => post { entity(as[ScriveRequest]) { scrive => onSuccess( elevationService ? ElevationService.Process(long, lat, bodyParams) ) { actorReply => complete(actorReply) } } } You can also use & to combine two directives more directly: (path("ElevationService" / DoubleNumber /...