playframework-2.6

customize the error page from Play Framework

谁说胖子不能爱 提交于 2019-12-11 19:36:24
问题 In case there is a compilation or runtime issue in Play Framework , error is returned to the client on receiving HTTP request. Which part of Play Framework creates and send the HTML? Can I customize it? For eg., my code throws an Exception on application loading. I see the following page I want to customize this page so that it looks/feels like website's page. Also, instead of HTML body, could I send a JSON body? UPDATE Looking at the stack trace of my application, the application loading

Failed to load data source for config using Play-2.6 and Quill.io

混江龙づ霸主 提交于 2019-12-11 18:21:25
问题 I'm currently getting an error when I try to run my Play app. It says Failed to load data source but then it looks like it is indeed loading the data source. I'm very new to Play and Scala and the rest of my team is also new, so apologies if this is a silly error or if I'm missing some code samples. Database app-users with owner root exists on my local and I don't believe root has a password (created using the createuser tool). Any ideas on what could cause this? Or what I am missing? Error:

Invalid type error when using Datastax Cassandra Driver

泄露秘密 提交于 2019-12-11 14:35:42
问题 I have a case class which represents partition key values. case class UserKeys (bucket:Int, email: String) I create query Clauses as follows: def conditions(id: UserKeys):List[Clauses] = List( QueryBuilder.eq("bucket", id.bucket), //TODOM - pick table description from config/env file. QueryBuilder.eq("email", id.email) ) And use the query as follows val selectStmt = select() .from(tablename) .where(QueryBuilder.eq(partitionKeyColumns(0), whereClauseList(0))).and(QueryBuilder.eq

Addition of an attribute to a Play request makes a new instance of request?

杀马特。学长 韩版系。学妹 提交于 2019-12-11 08:29:23
问题 If, like me, you're coming from the Java Servlet world, Play's support for request attributes (recently introduced in release 2.6) was only too long in coming. Now, that I've had a chance to look at it in some detail though, I wonder if it's usable. Verbatim from the docs (Scala): // Create a TypedKey to store a User object object Attrs { val User: TypedKey[User] = TypedKey.apply[User]("user") } // Get the User object from the request val user: User = req.attrs(Attrs.User) // Put a User

How can I disable the CSRF filter on Play 2.6?

折月煮酒 提交于 2019-12-10 18:39:30
问题 I've been trying to use Postman with my Play Framework API, but I keep running into problems related to the CSRF Filter. I've browsed a few forums (including SO) looking for a fix to this, and the proverbial advice seems to be adding: play.filters.disabled+=play.filters.csrf.CSRFFilter to the application.conf file. I've tried performing that fix, but even when I do so, I continue to get this error in the console logs: [warn] p.filters.CSRF - [CSRF] Check failed because no token found in

How to apply play-evolutions when running tests in play-framework?

陌路散爱 提交于 2019-12-10 12:42:22
问题 I have problems with evolutions when running tests in play framework using playframework v2.6.6 for scala play-slick v3.0.2 play-slick-evolutions v3.0.2 The test looks like this: class TestFooController extends PlaySpec with GuiceOneServerPerSuite { "foo endpoint should store some data" in { val wsClient = app.injector.instanceOf[WSClient] val url = s"http://localhost:$port/foo" val requestData = Json.obj("foo" -> "bar") val response = await(wsClient.url(url).post(requestData)) response

Play subproject can't import Play-json classes on IntelliJ

孤街浪徒 提交于 2019-12-08 07:16:42
问题 I've split my app into sub-projects for better organization, however. My core sub-module which is a play app can't import play.api.libs.json.Json Here is my build.sbt # project/Common.scala import sbt._ import sbt.Keys._ object Common { val settings = Seq( organization := "com.company.app", scalaVersion := "2.12.5" ) val dependencies = new { val macwireVersion = "2.3.0" val reactiveMongoVersion = "0.13.0-play26" val slickVersion = "3.0.3" val postgresVersion = "42.2.2" val

how Play sends CSRF token?

时光总嘲笑我的痴心妄想 提交于 2019-12-07 18:04:58
问题 When my application retrieves index.html and other js and css files from the server, I do not see an csrf token in headers or cookies. How does play sends csrf token? My UI is an Angular application being served from play . From the documents, I read about csrf token that This token gets placed either in the query string or body of every form submitted, and also gets placed in the user’s session The documentation also says that To ensure that a CSRF token is available to be rendered in forms,

how Play sends CSRF token?

两盒软妹~` 提交于 2019-12-06 02:38:17
When my application retrieves index.html and other js and css files from the server, I do not see an csrf token in headers or cookies. How does play sends csrf token? My UI is an Angular application being served from play . From the documents, I read about csrf token that This token gets placed either in the query string or body of every form submitted, and also gets placed in the user’s session The documentation also says that To ensure that a CSRF token is available to be rendered in forms, and sent back to the client, the global filter will generate a new token for all GET requests that

How to handle Action which returns Accumultor[ByteString,Result] in unit test

强颜欢笑 提交于 2019-12-02 08:34:51
My Action returns Accumulator[ByteString,Result] . I want to unit test the Accumulator . How can I test it? I am trying to use contentAsJson which accepts a variable of type Accumulator[ByteString,Result] but the Right side of Either is not giving me the content. The following is the test case. "newQuestion" should { "should return error if tag information in the question isn't in correct format" in { val testEnv = new QuestionsControllerSpecTestEnv(components=components) val body = s""" |{ | "practice-question":{ | "description": "some description", | "hints": ["hint1","hint2"], | "image": [