playframework-2.5

Playframework and Twitter Streaming API

*爱你&永不变心* 提交于 2019-12-25 08:57:22
问题 How to read response data from Twitter Streaming API - POST statuses/filter ? I have established connection and I receive 200 status code, but I don't know how to read tweets. I just want to println tweets as they coming. ws.url(url) .sign(OAuthCalculator(consumerKey, requestToken)) .withMethod("POST") .stream() .map { response => if(response.headers.status == 200) println(response.body) } EDIT: I found this solution ws.url(url) .sign(OAuthCalculator(consumerKey, requestToken)) .withMethod(

Playframework: Custom template path

匆匆过客 提交于 2019-12-25 07:38:17
问题 I was wondering if it is possible to override/add to the template paths for Playframework? For instance, the default templates are looked under views folder and are compiled automatically. These templates are further reachable directly using a URL without any additional config. ---app |-controllers |-models |-templates //How do I compile templates under this folder? |-views What I would like to know is if it is possible to add a custom path in addition to the views folder that is also

What is the alternative for Play.application()

陌路散爱 提交于 2019-12-24 01:06:09
问题 I am new to Play framework. I wanted to read a file which is in the conf folder. So I used Play.application().classloader().getResources("Data.json").nextElement().getFile() But I got to know that play.Play is deprecated now. What can I use to read the file. I read this article and can hardly understand what it says. 回答1: Just inject the Application in the class where you need it. Supposing it is in a controller: import play.Application; import javax.inject.Inject; import javax.inject

Testing request with CSRF Token in Play framework 2.5 (Scala)

孤人 提交于 2019-12-22 04:00:57
问题 I'm stuck on a little problem with my functionnal testing. I have a Play! 2.5 scala project in which I added CSRF verification on some forms, the associated scala-test units test failed, as expected, with the error : java.lang.RuntimeException: No CSRF token present! I'm using FakeRequest with routes in order to test them : val fakeRequest = FakeRequest(GET, s"/backOffice/login") val Some(result) = route(app, fakeRequest) How could I add the CRSF Token in order to render my test successful

Automatically inject WebJarAssets in Play 2.5 HTML template?

☆樱花仙子☆ 提交于 2019-12-21 14:07:09
问题 In my Play HTML template inside my custom module, I have the following line of code: <script type="text/javascript" src="@controllers.core.routes.WebJarAssets.at(WebJarAssets.locate("jquery.min.js"))"></script> This references a WebJarAssets class in the core module that looks like this: package controllers.core import javax.inject._ import play.api.http.HttpErrorHandler import play.api.{Environment, Configuration} class WebJarAssets @Inject()(errorHandler: HttpErrorHandler, configuration:

Play 2.5.3: Using dependency injection to get configuration values

♀尐吖头ヾ 提交于 2019-12-20 12:31:27
问题 I'm trying to migrate a Playframework application from 2.4 to 2.5.3 and I have problems to get values from application.conf file: Before to get a value of from application.conf what I do was: Play.application().configuration().getString("label") Now as Play.application() is deprecated, I should use Dependency injection. Based on the framework documentation I use the following instructions: Define import : import javax.inject.*; import play.Configuration; Define class property : @Inject

Slick Transactionally future is not invoked in Play for Scala [duplicate]

大兔子大兔子 提交于 2019-12-13 08:20:05
问题 This question already has answers here : Run transactionally and retrieve result in Future (2 answers) Closed 3 years ago . The code below prints '1' and never prints '2', as a result the browser hangs when it requests the page served by the index method. The future is never invoked. If the future.map statement is replaced with Await.result(future, Duration.Inf) the code works correctly. What is the problem? case class UserRole (sk: Int, name: String) class UserRoleDB(tag: Tag) extends Table

Angular Html5Mode PlayFramework gives 404 when refreshed

白昼怎懂夜的黑 提交于 2019-12-13 07:17:49
问题 I am setting up a Play Framework 2.5 server to use Angular 's SPA(single page App) approach and would like to use PathLocationStrategy that removes the HashTags( #example ) The page loads fine when I first hit the server, but if I refresh or come back after bookmarking it, gives 404 In the Angular documentation for Angular Router it states that server side configuration is required There's lots of info on how to do this using nginx or apache but how does one do it in Play without a proxy

Play Framework 2.5.x Scala Slick implementation style

空扰寡人 提交于 2019-12-12 18:13:19
问题 I have kind of philosophical question. I have been a very happy user of Play Framework for Java for couple years now. Now I am trying to dive into Scala and functional programming. In Java-based play I have been using Ebean, so according to Play documentation I extended Ebean Model class and implemented my own models. In each model I declared a static variable of type Finder in order to call queries. All of this is documented and working well. However in Scala-based Play (v2.5.x) there is not

No implementation for play.db.Database was bound

随声附和 提交于 2019-12-12 10:59:33
问题 Im having problem accessing db, when using hikaricp this is my reference.conf play { modules { enabled += "play.api.db.DBModule" enabled += "play.api.db.HikariCPModule" } # Database configuration db { # The name of the configuration item from which to read database config. # So, if set to db, means that db.default is where the configuration for the # database named default is found. config = "db" # The name of the default database, used when no database name is explicitly # specified. default