playframework-2.3

Access Request Body in essential filter Play Framework 2

China☆狼群 提交于 2019-11-30 22:57:05
I am new to Scala. As mentioned in play framework official documentation in https://www.playframework.com/documentation/2.3.x/ScalaHttpFilters : Play provides a lower level filter API called EssentialFilter which gives you full access to the body of the request. but there is not any method to accessing request body in requestHeader object. import play.api.Logger import play.api.mvc._ import play.api.libs.concurrent.Execution.Implicits.defaultContext object LoggingFilter extends EssentialFilter { def apply(nextFilter: EssentialAction) = new EssentialAction { def apply(requestHeader:

How to use Twitter Bootstrap 3 with play framework 2.3

我的未来我决定 提交于 2019-11-30 18:37:53
I have been trying adding bootstrap's js and css files to public/javascripts and public/stylesheets application in play framework application. I donno why but I get a blank output. Is it the correct way to proceed for bootstrap v3 with play v2.3? If not what's the correct procedure to do it? biesior DO NOT divide downloaded library manually, what for? It contains relative paths. Just unzip it i.e. into public/bootstrap folder and include JS/CSS from there as common public asset: <link rel="stylesheet" href="@routes.Assets.at("assets/bootstrap/css/bootstrap.css")"> <script type='text/javascript

Access Request Body in essential filter Play Framework 2

泪湿孤枕 提交于 2019-11-30 17:51:33
问题 I am new to Scala. As mentioned in play framework official documentation in https://www.playframework.com/documentation/2.3.x/ScalaHttpFilters : Play provides a lower level filter API called EssentialFilter which gives you full access to the body of the request. but there is not any method to accessing request body in requestHeader object. import play.api.Logger import play.api.mvc._ import play.api.libs.concurrent.Execution.Implicits.defaultContext object LoggingFilter extends

How do I catch json parse error when using acceptWithActor?

好久不见. 提交于 2019-11-30 15:53:23
问题 I use websockets with playframework 2.3. This is a snippet from official how-to page. def socket = WebSocket.acceptWithActor[JsValue, JsValue] { request => out => MyWebSocketActor.props(out) } When I use the code, How do I catch json parse error(RuntimeException: Error parsing JSON)? 回答1: Using the built in json frame formatter, you can't, here's the source code: https://github.com/playframework/playframework/blob/master/framework/src/play/src/main/scala/play/api/mvc/WebSocket.scala#L80 If

How do I catch json parse error when using acceptWithActor?

家住魔仙堡 提交于 2019-11-30 15:22:21
I use websockets with playframework 2.3. This is a snippet from official how-to page . def socket = WebSocket.acceptWithActor[JsValue, JsValue] { request => out => MyWebSocketActor.props(out) } When I use the code, How do I catch json parse error(RuntimeException: Error parsing JSON)? Using the built in json frame formatter, you can't, here's the source code: https://github.com/playframework/playframework/blob/master/framework/src/play/src/main/scala/play/api/mvc/WebSocket.scala#L80 If Json.parse throws an exception, it will throw that exception to Netty, which will alert the Netty exception

Play 2.3 implicit json conversion causes null pointer exception

牧云@^-^@ 提交于 2019-11-30 11:46:49
I'm trying to parse json into my case class DealFormMap case class DealFormMap(limit: Option[Int], filter: Option[DealFormFilterMap]) case class DealFormFilterMap(date: Option[String], code: Option[String]) implicit val dealFormMapReads: Reads[DealFormMap] = ( (JsPath \ "limit").readNullable[Int] and (JsPath \ "filter").readNullable[DealFormFilterMap] )(DealFormMap) implicit val dealFormFilterMapReads: Reads[DealFormFilterMap] = ( (JsPath \ "date").readNullable[String] and (JsPath \ "code").readNullable[String] )(DealFormFilterMap) JSON in question and parsing attempt val str = """{"limit":10,

Caching an action in a multi-language website using Play Framework's Cached API

天大地大妈咪最大 提交于 2019-11-30 11:03:00
In order to cache actions per label and language for a given number of seconds, I wrote the following helper method (where label, is the name I give to my action): def cacheResponseFor(label: String, duration: Int)(action: EssentialAction) = { Cached({r: RequestHeader => (label + getLanguage(r))}, duration){ action } } def getLanguage(request: RequestHeader): String = { request.cookies .get(helpers.SessionHelpers.LANGUAGE_SESSION) .map(_.value) .getOrElse(helpers.LanguageHelpers.FRENCH) } But I'm experiencing something weird, when I try to cache an Action for 60s and switch languages in the

How to fix “SLF4J: Class path contains multiple SLF4J bindings” at startup of Play 2.3.x?

ε祈祈猫儿з 提交于 2019-11-30 03:22:47
问题 I upgraded my version of Play and other libraries and I now see this: SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/home/paul/.ivy2/cache/org.slf4j/slf4j-nop/jars/slf4j-nop-1.7.7.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/home/paul/.ivy2/cache/org.slf4j/slf4j-jdk14/jars/slf4j-jdk14-1.7.7.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/home/paul/.ivy2/cache/org.slf4j/slf4j-simple

How to use Twitter Bootstrap 3 with play framework 2.3

此生再无相见时 提交于 2019-11-30 02:59:11
问题 I have been trying adding bootstrap's js and css files to public/javascripts and public/stylesheets application in play framework application. I donno why but I get a blank output. Is it the correct way to proceed for bootstrap v3 with play v2.3? If not what's the correct procedure to do it? 回答1: DO NOT divide downloaded library manually, what for? It contains relative paths. Just unzip it i.e. into public/bootstrap folder and include JS/CSS from there as common public asset: <link rel=

Was asynchronous jobs removed from the Play framework? What is a better alternative?

随声附和 提交于 2019-11-29 12:26:41
I wanted to use Job so I can kick them off on the start of application. Now it seems like it has been removed from Play completely? I saw some samples where people create a Global class, but not entirely sure if/how I should use that to replace Job . Any suggestions? Edit: If you gonna downvote, give a reason. Maybe I'm missing something in the question, maybe this doesn't belong here. At least something... The Job class was removed in Play 2.0. You have some alternatives though depending on your Play version and if you need asynchrony or not: Akka Actors For all version since Play 2.0 you can