spray

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

China☆狼群 提交于 2019-12-21 07:34:22
问题 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]) { person => complete(person) } } However I get when I try to compile this: src/main/scala/com/example/ServiceActor.scala:61: error: could not find implicit value for parameter um: spray.httpx.unmarshalling.FromRequestUnmarshaller[com.example.Person] I don't

How to fix the Dropping Close since the SSL connection is already closing error in spray

三世轮回 提交于 2019-12-21 03:09:29
问题 I’m making a call to an API, but most of the time I keep getting an error: “ Dropping Close since the SSL connection is already closing ” and “ Premature connection close (the server doesn't appear to support request pipelining) .” Like 90% of the time I get that error, meaning: on very rare occasions the query does return the data it supposed to. To make sure this wasn’t the API’s server issue, I replicate the same query using Node.js (Express and Request libs) and it works every time. It

Scala parameters pattern (Spray routing example)

江枫思渺然 提交于 2019-12-20 10:47:30
问题 Sorry about the vague title...wasn't sure how to characterize this. I've seen/used a certain code construction in Scala for some time but I don't know how it works. It looks like this (example from Spray routing): path( "foo" / Segment / Segment ) { (a,b) => { // <-- What's this style with a,b? ... }} In this example, the Segements in the path are bound to a and b respectively inside the associated block. I know how to use this pattern but how does it work? Why didn't it bind something to

How to cut a long ScalaTest spec to pieces

*爱你&永不变心* 提交于 2019-12-20 04:48:27
问题 I'm testing a REST API, and the code goes like this: Setting up stuff, populating a database using PUSH calls Testing API a Testing API b ... The code is currently in one rather huge FlatSpec : class RestAPITest extends FlatSpec with Matchers with ScalatestRouteTest with SprayJsonSupport I would like to chop the "Testing API a/b/..." parts out, to have the code more manageable. Trying to do that seems like a no-no: what's the type of it - how to pass that on, etc. etc. So, what's the

Akka consolidate concurrent database requests

删除回忆录丶 提交于 2019-12-19 10:22:46
问题 I want to be able to make concurrent requests to multiple data repositories and consolidate the results. I am trying to understand if my approach is at all valid or if there is a better way to approach this problem. I am definitely new to Akka / Spray / Scala and really want to get a better understanding of how to properly build these components. Any suggestions / Tips would be greatly appreciated. Trying to wrap my head around the use of actors and futures for this type of implementation.

could not find implicit value for parameter marshaller: spray.httpx.marshalling.ToResponseMarshaller

谁说胖子不能爱 提交于 2019-12-19 09:50:07
问题 I'm using val akkaV = "2.2.3" val sprayV = "1.2.0" Seq( "io.spray" % "spray-can" % sprayV, "io.spray" % "spray-routing" % sprayV, "io.spray" %% "spray-json" % "1.2.5", "io.spray" % "spray-testkit" % sprayV, "com.typesafe.akka" %% "akka-actor" % akkaV, "com.typesafe.akka" %% "akka-testkit" % akkaV, And getting this error: could not find implicit value for parameter marshaller: spray.httpx.marshalling.ToResponseMarshaller[List[org.bwi.models.Cluster]] with this code: object JsonImplicits

How can I fix the missing implicit value for parameter ta: TildeArrow in a test spec

放肆的年华 提交于 2019-12-18 14:15:41
问题 I'm working on a simple test spec using spray and I can't get it to compile correctly, don't know if I'm doing anything wrong. My version of scala is 2.9.3 and spray 1.0.1 (Updating either of them is not a suitable option). Here's my test spec's code: import org.specs2.mutable.Specification import spray.testkit.Specs2RouteTest import spray.http._ import akka.util.Duration import java.util.concurrent.TimeUnit import service.MyProxy abstract class MyTestSpec extends Specification with

How to return image/png media type response in Spray?

妖精的绣舞 提交于 2019-12-13 02:27:12
问题 I want to return image/PNG as response to calling URL. How can I do it in Spray? 回答1: This may help: import java.io._ import spray.http._ import MediaTypes._ sender ! HttpResponse(entity = HttpEntity(`image/png`, HttpData(new File("my.png")))) See also, HttpMessage, HttpEntity, HttpData and MediaTypes. You can do same for HttpRequest as well. You can use Array[Byte] or ByteString instead of File . Checked for Spray 1.3.x . 来源: https://stackoverflow.com/questions/28125752/how-to-return-image

akka-http : could not find implicit value for parameter unmarshalling

房东的猫 提交于 2019-12-12 15:25:57
问题 My spray json support looks like this object MarshallingSupport extends SprayJsonSupport { implicit def json4sFormats: Formats = DefaultFormats } And in my route I want to map the request to a dto object Main extends App with AppConfig with BaseService with MainActorSystem { val processor = system.actorOf(Props(), "processorActor") val view = system.actorOf(Props(), "processorActor") override protected implicit val executor: ExecutionContext = system.dispatcher override protected val log:

Why are my requests handled by a single thread in spray-http?

左心房为你撑大大i 提交于 2019-12-12 11:31:34
问题 I set up an http server using spray-can, spray-http 1.3.2 and akka 2.3.6. my application.conf doesn't have any akka (or spray) entries. My actor code: class TestActor extends HttpServiceActor with ActorLogging with PlayJsonSupport { val route = get { path("clientapi"/"orders") { complete {{ log.info("handling request") System.err.println("sleeping "+Thread.currentThread().getName) Thread.sleep(1000) System.err.println("woke up "+Thread.currentThread().getName) Seq[Int]() }} } } override def