playframework

Play Framework - how to ignore some fields for Json Serialisation?

假如想象 提交于 2020-08-08 14:50:42
问题 I have case class case class User ( id: Option[Long] = None, username: String, password: Option[String] = None, ) And here is json serialiser for this case class object User { implicit val userWrites: Writes[User] = ( (JsPath \ "id").write[Option[Long]] and (JsPath \ "username").write[String] and (JsPath \ "password").write[Option[String]] and )(unlift(User.unapply)) } But I don't want to expose password field in api response. How can I achieve it? I use also use this for Slick to read/write

How to create a WSResponse object from string for Play WSClient

谁都会走 提交于 2020-07-20 10:53:09
问题 Documentation suggests testing API client based on WSClient using a mock web service, that is, create a play.server.Server which will respond to real HTTP requests. I would prefer to create WSResponse objects directly from files, complete with status line, header lines and body, without real TCP connections. That would require less dependencies and run faster. Also there may be other cases when this is useful. But I can't find a simple way to do it. It seems all implementations wrapped by

Play framework, i18n “messages.*” in subfolders

不想你离开。 提交于 2020-06-17 06:59:32
问题 I want to put conf/messages into subfolder, like conf/lang/messages . There is nothing about this in documentation: https://www.playframework.com/documentation/2.4.x/JavaI18N. Did someone resolve this problem ? 回答1: This Messages.scala source code has a clue: protected val messagesPrefix = config.getDeprecated[Option[String]]("play.i18n.path", "messages.path") I have not tried it in 2.4 yet, but it looks worth taking for a spin. 回答2: You can specify the sub-directory in application.conf by

Play framework, i18n “messages.*” in subfolders

只谈情不闲聊 提交于 2020-06-17 06:59:15
问题 I want to put conf/messages into subfolder, like conf/lang/messages . There is nothing about this in documentation: https://www.playframework.com/documentation/2.4.x/JavaI18N. Did someone resolve this problem ? 回答1: This Messages.scala source code has a clue: protected val messagesPrefix = config.getDeprecated[Option[String]]("play.i18n.path", "messages.path") I have not tried it in 2.4 yet, but it looks worth taking for a spin. 回答2: You can specify the sub-directory in application.conf by

HTTP Status Code from URL in Javascript

懵懂的女人 提交于 2020-05-27 12:39:32
问题 I'm trying to find a function that return HTTP Status Code from an URL, and then "make something" based on the returned statuses (404, 416, 200 etc...) Can someone help me? I've tried the other functions posted here on StackOverflow but anyone was usefull for my purpose. I need to integrate this function inside my PlayFramework web-app. Thanks a lot 回答1: Can you try the following ..? function getStatus(url) { var request = new XMLHttpRequest(); request.onreadystatechange = function() { if

Play file upload : warn: Sending an 2xx 'early' response before end of request was received

大憨熊 提交于 2020-05-27 05:35:12
问题 Experimenting with the "Play Scala File Upload Example", I've got the following warning: [warn] a.a.ActorSystemImpl - Sending an 2xx 'early' response before end of request was received... Note that the connection will be closed after this response. Also, many clients will not read early responses! Consider only issuing this response after the request data has been completely read! Is there any way to avoid this warning ? The full source code is available here: https://github.com/playframework

Error when trying to run a Play Scala app with sbt after fresh install on Catalina: “Error loading JNotify watch service: null”

混江龙づ霸主 提交于 2020-05-26 04:13:08
问题 After moving to Catalina and re-installing everything, no way to run my Play Scala app. After doing sbt then run , I get this error: [warn] Error loading JNotify watch service: null Everything was installed with brew from this brewfile (I didn't paste the complete file): tap "AdoptOpenJDK/openjdk" # Mac apps cask "adoptopenjdk8" brew "sbt@0.13" brew "jenv" Java version: openjdk version "1.8.0_242" OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_242-b08) OpenJDK 64-Bit Server VM

Error when trying to run a Play Scala app with sbt after fresh install on Catalina: “Error loading JNotify watch service: null”

吃可爱长大的小学妹 提交于 2020-05-26 04:10:24
问题 After moving to Catalina and re-installing everything, no way to run my Play Scala app. After doing sbt then run , I get this error: [warn] Error loading JNotify watch service: null Everything was installed with brew from this brewfile (I didn't paste the complete file): tap "AdoptOpenJDK/openjdk" # Mac apps cask "adoptopenjdk8" brew "sbt@0.13" brew "jenv" Java version: openjdk version "1.8.0_242" OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_242-b08) OpenJDK 64-Bit Server VM