spray

Parsing a simple array with Spray-json

為{幸葍}努か 提交于 2020-01-02 02:59:05
问题 I'm trying (and failing) to get my head around how spray-json converts json feeds into objects. If I have a simple key -> value json feed then it seems to work ok but the data I want to read comes in a list like this: [{ "name": "John", "age": "30" }, { "name": "Tom", "age": "25" }] And my code looks like this: package jsontest import spray.json._ import DefaultJsonProtocol._ object JsonFun { case class Person(name: String, age: String) case class FriendList(items: List[Person]) object

marathon-lb health check failing on all spray.io containers

早过忘川 提交于 2020-01-01 19:35:30
问题 I'm running DC/OS 1.7 with marathon-lb. spray.io 1.3.3 is returning 400 to all marathon-lb/HAProxy heath check calls: request has a relative URI and is missing a Host header so marathon-lb never routes any requests to the service. The health check in the marathon json is: "healthChecks": [ { "path": "/health", "protocol": "HTTP", "portIndex": 0, "gracePeriodSeconds": 10, "intervalSeconds": 2, "timeoutSeconds": 10, "maxConsecutiveFailures": 10, "ignoreHttp1xx": false } ], and the logging by

marathon-lb health check failing on all spray.io containers

偶尔善良 提交于 2020-01-01 19:35:19
问题 I'm running DC/OS 1.7 with marathon-lb. spray.io 1.3.3 is returning 400 to all marathon-lb/HAProxy heath check calls: request has a relative URI and is missing a Host header so marathon-lb never routes any requests to the service. The health check in the marathon json is: "healthChecks": [ { "path": "/health", "protocol": "HTTP", "portIndex": 0, "gracePeriodSeconds": 10, "intervalSeconds": 2, "timeoutSeconds": 10, "maxConsecutiveFailures": 10, "ignoreHttp1xx": false } ], and the logging by

marathon-lb health check failing on all spray.io containers

丶灬走出姿态 提交于 2020-01-01 19:35:04
问题 I'm running DC/OS 1.7 with marathon-lb. spray.io 1.3.3 is returning 400 to all marathon-lb/HAProxy heath check calls: request has a relative URI and is missing a Host header so marathon-lb never routes any requests to the service. The health check in the marathon json is: "healthChecks": [ { "path": "/health", "protocol": "HTTP", "portIndex": 0, "gracePeriodSeconds": 10, "intervalSeconds": 2, "timeoutSeconds": 10, "maxConsecutiveFailures": 10, "ignoreHttp1xx": false } ], and the logging by

How do i specify spray Content-Type response header?

旧时模样 提交于 2019-12-30 08:19:29
问题 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 ! HttpResponse(entity = """{ "key": "value" }""" // here i want to specify also response header i would like to explicitly set it and not get it implicitly 回答1: If you still want to use spray can, then you have two options, based on that HttpResponse is a case class

Spray Routing Doesn't match anything

我与影子孤独终老i 提交于 2019-12-25 12:29:40
问题 I have tried many things, but no matter what I do in my tests (which simply sends a PUT request to "create a user") the logs do not enter any of the pathPrefix and just go to the end and fail to match anything. Can anyone offer insight? Below is the class I have written as well as the simple test (which doesn't even check anything yet) I know overall it is rather rudimentary and I am not doing things great, but it's just something I threw together to the point where I felt i could do a few

Uncaught fatal error from thread [default-akka.actor.default-dispatcher-5] shutting down ActorSystem

前提是你 提交于 2019-12-25 01:19:03
问题 In my application, I am retriving data from cassandra and providing the rest api using akka spray. It is working fine when I am running through IDE. But when I am running through Spark submit locally on my machine got error as given below [ERROR] [04/05/2016 10:43:38.687] [default-akka.actor.default-dispatcher-5] [ActorSystem(default)] Uncaught fatal error from thread [default-akka.actor.default-dispatcher-5] shutting down ActorSystem [default] java.lang.NoSuchMethodError: org.apache.spark

When testing Spray services with Scalatest, how to introduce implicit values?

只愿长相守 提交于 2019-12-24 15:21:48
问题 I have a service: trait MyService extends HttpService { def getDao(implicit dao: SomeDAO) = dao def someRoute = path("foo") { get { complete(getDao getSomething) } } } Then, I have an actor: class MyActor extends MyService with Actor { override def receive: Receive = runRoute(someRoute) def actorRefFactory: ActorRefFactory = context } My test class looks like this: class MyServiceTest extends FlatSpec with ScalatestRouteTest with MyService with Matchers with MockFactory { override implicit

Understanding Spray: Demistification

て烟熏妆下的殇ゞ 提交于 2019-12-24 14:13:27
问题 Can someone help me get a hold on the spray code to better understand how to spray ? I'm the context of sending a file as multipart data. The code that was suggested to me is : import akka.actor.ActorSystem import spray.client.pipelining._ import spray.http.{MediaTypes, BodyPart, MultipartFormData} object UploadFileExample extends App { implicit val system = ActorSystem("simple-spray-client") import system.dispatcher // execution context for futures below val pipeline = sendReceive val

spray, scala : change the timeout

强颜欢笑 提交于 2019-12-24 08:59:40
问题 I want to change the timeout in a spray application, but what is the simplest way to achieve this? I saw some examples on github but they are rather complicated. thanks. I tried this : class MyServiceActor extends Actor with MyService { sender ! SetRequestTimeout(scala.concurrent.duration.Duration(120,"second")) sender ! spray.io.ConnectionTimeouts.SetIdleTimeout(scala.concurrent.duration.Duration(120,"second")) // the HttpService trait defines only one abstract member, which // connects the