playframework-2.0

Scala play json combinators for validating equality

和自甴很熟 提交于 2021-02-18 13:18:00
问题 I'm using play 2.2.0 Reads for validating incoming request in my application. I'm trying to implement a very simple thing with json API. I have a json like this: { "field1": "some value", "field2": "some another value" } I already have Reads that checks for other stuff like minimal length case class SomeObject(field1: String, field2: String) implicit val someObjectReads = ( (__ \ "field1").read(minLength[String](3)) ~ (__ \ "field2").read(minLength[String](3)) )(SomeObject) I want to create a

Scala play json combinators for validating equality

雨燕双飞 提交于 2021-02-18 13:08:29
问题 I'm using play 2.2.0 Reads for validating incoming request in my application. I'm trying to implement a very simple thing with json API. I have a json like this: { "field1": "some value", "field2": "some another value" } I already have Reads that checks for other stuff like minimal length case class SomeObject(field1: String, field2: String) implicit val someObjectReads = ( (__ \ "field1").read(minLength[String](3)) ~ (__ \ "field2").read(minLength[String](3)) )(SomeObject) I want to create a

Scala play json combinators for validating equality

对着背影说爱祢 提交于 2021-02-18 13:04:33
问题 I'm using play 2.2.0 Reads for validating incoming request in my application. I'm trying to implement a very simple thing with json API. I have a json like this: { "field1": "some value", "field2": "some another value" } I already have Reads that checks for other stuff like minimal length case class SomeObject(field1: String, field2: String) implicit val someObjectReads = ( (__ \ "field1").read(minLength[String](3)) ~ (__ \ "field2").read(minLength[String](3)) )(SomeObject) I want to create a

playframework: how to redirect to a post call inside controller action method

落爺英雄遲暮 提交于 2021-02-10 22:41:14
问题 I have some route define as: Post /login controllers.MyController.someMethod() and inside someMethod I use DynamicForm to extract parameters from the post request. works fine from browser or any client using Post method. But if I need to call this url inside some action method (lets say someAnotherMethod ) and want to pass some parameters also, how can I achieve this? What I mean is: public static Result someAnotherMethod() { // want to put some data in post request body and return redirect

Using MockitoSugar of scalatestplus-play deprecated

元气小坏坏 提交于 2021-02-10 16:18:51
问题 I'm using "scalatestplus-play" % "5.1.0" , and I'm trying to bring MockitoSugar to my class like I did in earlier projects: class MyTestSpec extends AnyFreeSpec with MockitoSugar so I can use the mock[MyClass] function and now it docent exists, can't find in the documentation something else. in my earlier projects I used "scalatestplus-play" % "4.0.3" , I'm sure there is a different way now but can't find what it is 回答1: First option you have, is to use scalatestplus-mockito, where you can

How to get an actor reference (ActorRef) from ActorFlow?

非 Y 不嫁゛ 提交于 2021-02-08 02:21:18
问题 According to the Play documentation on WebSockets the standard way to establish a WebSocket is to use ActorFlow.actorRef , which takes a function returning the Props of my actor. My goal is to get a reference to this underlying ActorRef , for instance in order to send a first message or to pass the ActorRef to another actor's constructor. In terms of the minimal example from the documentation, I'm trying to achieve this: class WebSocketController @Inject() (implicit system: ActorSystem,

How to get an actor reference (ActorRef) from ActorFlow?

旧城冷巷雨未停 提交于 2021-02-08 02:18:28
问题 According to the Play documentation on WebSockets the standard way to establish a WebSocket is to use ActorFlow.actorRef , which takes a function returning the Props of my actor. My goal is to get a reference to this underlying ActorRef , for instance in order to send a first message or to pass the ActorRef to another actor's constructor. In terms of the minimal example from the documentation, I'm trying to achieve this: class WebSocketController @Inject() (implicit system: ActorSystem,

Vector or MutableList / ListBuffer for performance

落爺英雄遲暮 提交于 2021-02-07 03:30:36
问题 Apologies if this is a duplicate - I did a few searches and didn't quite find what I need. We have a performance critical piece of our application that converts a Play 2.0 Enumerator (can be thought of as a Stream ) of incoming data to a List (or similar). We will use the fold method on Enumerator and the question is what will be the most performant way to do it. (I will use Stream instead of Enumerator in the code, but the idea should be the same.) val incoming: Stream[Int] = ??? val result:

Vector or MutableList / ListBuffer for performance

回眸只為那壹抹淺笑 提交于 2021-02-07 03:29:05
问题 Apologies if this is a duplicate - I did a few searches and didn't quite find what I need. We have a performance critical piece of our application that converts a Play 2.0 Enumerator (can be thought of as a Stream ) of incoming data to a List (or similar). We will use the fold method on Enumerator and the question is what will be the most performant way to do it. (I will use Stream instead of Enumerator in the code, but the idea should be the same.) val incoming: Stream[Int] = ??? val result: