playframework-2.5

Play Framework PathBindable with Dependency Injection

为君一笑 提交于 2019-12-10 12:55:57
问题 I'm migrating a Scala Play application to 2.5 and am currently moving my components to dependency injection. There's one place left where I'm at a loss how to do it though. I have a PathBindable implicit conversion defined in the companion object: object Task { implicit def pathBindable(implicit stringBinder: PathBindable[String]) = new PathBindable[Task] { ... } } The implementation of the PathBindable needs to look up the object from a repository, but I haven't found a way to dependency

How to properly serve csv data with play framework

最后都变了- 提交于 2019-12-10 11:21:09
问题 I have a simple app which asks a DB a question, and then serves returns some data as simple text. The 'plain/text' response happens to be in CSV format. It gets read in by another program (matlab, through webread), and then we 'do analysis'. Now, it appears that the play framework has changed some settings. Whereas before this code; def singleEventsMultipleRegions(peril: String, region: List[String]) = Action.async { val theResult = db.run(filter(peril, region).result) val intermediate =

Play 2.5 upgrade error: CompletionException - There is no HTTP Context available from here [duplicate]

流过昼夜 提交于 2019-12-10 10:28:10
问题 This question already has answers here : Play Framework 2.5 JavaAsync throwing CompletionException (2 answers) Closed 2 years ago . After upgrading from Play 2.4 to Play 2.5 on a sample app, when I run ./activator clean dist , I get no errors however after going to a specific endpoint http://localhost:9000/java/proxy , I'm receiving the following error: [error] application - ! @72keog237 - Internal server error, for (GET) [/java/proxy] -> play.api.http.HttpErrorHandlerExceptions$$anon$1:

Slick: combine actions with a Seq of DBIOAction

两盒软妹~` 提交于 2019-12-09 18:24:08
问题 I have the (working) following code: val actions = (for { _ <- slickUsers.insertOrUpdate(dbUser) loginInfo <- loginInfoAction _ <- slickUserLoginInfos += DBUserLoginInfo(dbUser.userID, loginInfo.id.get) } yield ()).transactionally with loginInfoAction being a DBIOAction. I would like to change loginInfoActions to a Seq of DBIOAction and for each of them, execute the same DBUserLoginInfo action afterwards. I tried this stupidly: val actions = (for { _ <- slickUsers.insertOrUpdate(dbUser)

SOAP webservice client in Play Framework 2.5.1

≯℡__Kan透↙ 提交于 2019-12-08 10:14:12
问题 I'm trying to develop SOAP webservice client using Play Webservice API, but I cant figure out how to do this. I found link: https://www.playframework.com/documentation/2.5.x/JavaWS But i don't see any example code, how to use WSClient to consume SOAP webservice. Any advice greatly appreciated, thanks. 回答1: There are basically 2 ways to consume SOAP web services with Play (I have added 2 just for the sake of completeness) Using the Play WS module (as you have tried) - as you are going to be

scala iteratee to recursively process files and subdirectories

夙愿已清 提交于 2019-12-08 07:31:21
问题 I want to apply a function for every file in a directory and subdirectories, as follows: def applyRecursively(dir: String, fn: (File) => Any) { def listAndProcess(dir: File) { dir.listFiles match { case null => out.println("exception: dir cannot be listed: " + dir.getPath); List[File]() case files => files.toList.sortBy(_.getName).foreach(file => { fn(file) if (!java.nio.file.Files.isSymbolicLink(file.toPath) && file.isDirectory) listAndProcess(file) }) } } listAndProcess(new File(dir)) } def

How to redirect request in play framework with scala?

三世轮回 提交于 2019-12-08 03:42:02
问题 I am using play framework 2.5. In my application i want to intercept each request to check whether any user exists or not in session of that request. if user does not exists then request redirect to the login page. So, my question is how can i achieve it in my application ? Thank You very much in advance. 回答1: After you check for the appropriate user Redirect(routes.Application.login()) I won't assume anything about your authentication strategy, but he're is a simple token-based

Play error on startup: No implementation for play.api.db.Database was bound

核能气质少年 提交于 2019-12-07 02:56:01
问题 When I attempt to run the Play application (Play 2.5.4) I get the following error: ProvisionException: Unable to provision, see the following errors: 1) No implementation for play.api.db.Database was bound. while locating play.api.db.Database for parameter 0 at ds.qb.manage.ManageQueryBuilder.<init>(ManageQueryBuilder.scala:30) while locating ds.qb.manage.ManageQueryBuilder for parameter 16 at router.Routes.<init>(Routes.scala:107) while locating router.Routes while locating play.api.inject

WebSocket.acceptWithActor and @Inject() in the Actor (Play 2.5)

[亡魂溺海] 提交于 2019-12-06 21:40:52
问题 WebSocket.acceptWithActor instantiates a new Akka actor without making use of Guice. With Play 2.4, using the injector for my actor was still possible by importing play.api.Play.current . Snippet from ReactiveMongo documentation: import scala.concurrent.Future import play.api.Play.current // should be deprecated in favor of DI import play.api.libs.concurrent.Execution.Implicits.defaultContext import play.modules.reactivemongo.ReactiveMongoApi import play.modules.reactivemongo.json.collection

Play error on startup: No implementation for play.api.db.Database was bound

时光总嘲笑我的痴心妄想 提交于 2019-12-05 06:28:14
When I attempt to run the Play application (Play 2.5.4) I get the following error: ProvisionException: Unable to provision, see the following errors: 1) No implementation for play.api.db.Database was bound. while locating play.api.db.Database for parameter 0 at ds.qb.manage.ManageQueryBuilder.<init>(ManageQueryBuilder.scala:30) while locating ds.qb.manage.ManageQueryBuilder for parameter 16 at router.Routes.<init>(Routes.scala:107) while locating router.Routes while locating play.api.inject.RoutesProvider while locating play.api.routing.Router for parameter 0 at play.api.http