spray

parboiled2 and Spray cause conflicting cross-version suffixes

限于喜欢 提交于 2019-12-10 21:18:06
问题 I'm trying to add parboiled2 as a dependency to my project, and follow the Calculator example but it conflicts with spray. My current build.sbt file includes: "io.spray" %% "spray-json" % "1.3.1" withSources() withJavadoc(), "io.spray" %% "spray-can" % sprayV withSources() withJavadoc(), "io.spray" %% "spray-routing" % sprayV withSources() withJavadoc(), "io.spray" %% "spray-testkit" % sprayV % "test" withSources() withJavadoc(), When I add "org.parboiled" %% "parboiled" % "2.0.1" withSources

Is there an example of how to use akka-http with servlet container?

隐身守侯 提交于 2019-12-10 21:12:11
问题 Right now using spray with Servlet30ConnectorServlet successfully in tomcat and was hoping to find similar example usage with akka-http 回答1: I don't think there is any connector servlet in akka-http yet. You can have a look at the api here: Akka http API 来源: https://stackoverflow.com/questions/29629111/is-there-an-example-of-how-to-use-akka-http-with-servlet-container

Unsupported ciphersuite TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256

╄→尐↘猪︶ㄣ 提交于 2019-12-10 11:39:51
问题 I recently received a certificate from Commodo and I'm trying to integrate it with my Scala Spray Server. I have an trait to configure my Spray sever: import java.io.{BufferedInputStream, FileInputStream} import java.security.{SecureRandom, KeyStore} import java.security.cert.{X509Certificate, CertificateFactory} import javax.net.ssl.{TrustManagerFactory, KeyManagerFactory, SSLContext} import spray.io._ import org.apache.camel.util.jsse._ // for SSL support (if enabled in application.conf)

In spray how to unmarshall plain/text?

て烟熏妆下的殇ゞ 提交于 2019-12-10 10:37:16
问题 Can anybody show me an example in spray how to unmarshall POST with content type plain/text ? How to write the route? Thanks! 回答1: This is how the route would look like: post { entity(as[String]) { str => complete(str) } } A sample request would be: curl -X POST -d 'It works' localhost:8080 which echoes back the POST data. To get the whole sample app use this official template and add/edit the route. If you want to understand how it works in detail see this doc and this one. 来源: https:/

Extracting Raw JSON as String inside a Spray POST route

给你一囗甜甜゛ 提交于 2019-12-09 16:09:49
问题 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 TextMsgResponse . But for http://host:port/somepath/value2 I want to extract the post body just as a raw Json (e.g., { "name":"Jack", "age":30 } val myRoute = path("somepath" / Segment) { pathSegment => post { //use only POST requests pathSegment match {

How to structure a RESTful API with Spray.io?

妖精的绣舞 提交于 2019-12-09 15:39:44
问题 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. Can I forward requests from the root actor to other actors in my application based on paths and, inside these actors, define the related routes? Thanks 回答1: You can certainly forward requests from one actor to another, based on paths or whatever

Scala: Receiving Server-Sent-Events

╄→гoц情女王★ 提交于 2019-12-09 10:16:51
问题 Set-up: A project I am working on has a pub/sub server with an HTTP interface. Subscription works by accepting server-sent-events. curl -X GET server:port/topics/news which will be pushed whenever a message is published to the given topic URL curl -X PUT server:port/topics/news -d "Politician Lies!" Problem: I have a scala project which needs to subscribe to this pub/sub server. The Play! framework is able to handle this by using PlayWS with Enumeratee + Iteratee. Unfortunately, the PlayWS

What is a good way to handle default values with spray-json

我的梦境 提交于 2019-12-08 19:55:37
问题 In some cases default values make more sense than optionals in case classes: case class Car(numberOfWheels:Int = 4, color:String) case class Car(numbeOfWheels:Option[Int], color:String) //silly In the first case I'd expect to be able to easily convert the following json to an instance: {"color":"red"} But with a standard jsonFormat2(Car) , spray-json complains about missing value for numberOfWheels . How do I work around this most cleanly? 回答1: I stumbled upon the same problem. I've create a

How does Scala use explicit types when resolving implicits?

烈酒焚心 提交于 2019-12-08 17:45:37
问题 I have the following code which uses spray-json to deserialise some JSON into a case class, via the parseJson method. Depending on where the implicit JsonFormat[MyCaseClass] is defined (in-line or imported from companion object), and whether there is an explicit type provided when it is defined, the code may not compile. I don't understand why importing the implicit from the companion object requires it to have an explicit type when it is defined, but if I put it inline, this is not the case?

required: spray.httpx.marshalling.ToResponseMarshallable Error

纵饮孤独 提交于 2019-12-08 04:00:23
问题 Hey im pretty new to Spray and reactive mongo . Im trying to return a list of result as json but i'm having some issue with converting the result to list of json. this is my model import reactivemongo.bson.BSONDocumentReader import reactivemongo.bson.BSONObjectID import reactivemongo.bson.Macros case class Post(id: BSONObjectID, likes: Long, message: String, object_id: String, shares: Long) object Post { implicit val reader: BSONDocumentReader[Post] = Macros.reader[Post] } the Mongo method