scala/playframework
-
CustomExecutionContext 설정scala/playframework 2023. 3. 1. 22:13
Custom ExecutionContext 생성 import akka.actor.ActorSystem import play.api.libs.concurrent.CustomExecutionContext class PostExecutionContext @Inject()(actorSystem: ActorSystem) extends CustomExecutionContext(actorSystem, "repository.dispatcher") application.conf 에 ExecutionContext 설정 repository.dispatcher { executor = "thread-pool-executor" throughput = 1 thread-pool-executor { fixed-pool-size = 4..
-
ScalaTestscala/playframework 2023. 2. 19. 23:48
app/conf/routes GET /api controllers.ApiController.api(x: Int, y: Int ?= 10) app/services/Adder.scala package services import javax.inject.Singleton trait Adder { def add(x: Int, y: Int): Int } @Singleton class ServiceAdder extends Adder { override def add(x: Int, y: Int): Int = x + y } app/controllers/ApiController.scala package controllers import play.api.mvc._ import services.Adder import jav..
-
Using ScalikeJDBCscala/playframework 2023. 2. 19. 20:30
http://scalikejdbc.org/documentation/playframework-support.html https://github.com/scalikejdbc/scalikejdbc-play-support build.sbt libraryDependencies ++= Seq( jdbc, guice, "mysql" % "mysql-connector-java" % "8.0.32", "org.scalikejdbc" %% "scalikejdbc" % "3.5.0", "org.scalikejdbc" %% "scalikejdbc-config" % "3.5.0", "org.scalikejdbc" %% "scalikejdbc-play-initializer" % "2.8.0-scalikejdbc-3.5", "or..
-
Logging MDCscala/playframework 2023. 2. 19. 01:40
https://github.com/playframework/play-samples/blob/2.8.x/play-scala-rest-api-example/app/v1/post/PostActionBuilder.scala#L29 참고 ------------------------------------------------------------------------------------------------------------ 개인적으로 만들어 본 것 import org.slf4j.MarkerFactory import play.api.MarkerContext import play.api.mvc.RequestHeader import java.util.UUID object Application { // marker..
-
Deployscala/playframework 2023. 2. 19. 01:33
https://www.playframework.com/documentation/2.8.x/Deploying {{ service_home }}/bin/{{ program }} -Dapplication.home={{ service_home }} -Dlogger.file={{ service_home }}/conf/logback.xml -Dplay.http.secret.key=f4175469aec955dc23c054e41c4bbe48 -Dpidfile.path={{ service_home }}/server.pid -Dhttp.port=12132 -Dconfig.file={{ service_home }}/conf/application.conf
-
Filterscala/playframework 2023. 2. 19. 01:22
https://www.playframework.com/documentation/2.8.x/Filters import javax.inject._ import play.api.mvc._ import scala.concurrent.ExecutionContext /** * This is a simple filter that adds a header to all requests. It's * added to the application's list of filters by the * [[Filters]] class. * * @param ec This class is needed to execute code asynchronously. * It is used below by the `map` method. */ @..
-
Action compositionscala/playframework 2023. 2. 19. 01:02
https://github.com/playframework/play-samples/blob/2.8.x/play-scala-rest-api-example/app/v1/post/PostActionBuilder.scala 처럼 ActionBuilder 를 만드는 것도 좋은 것 같다. package controllers import play.api.Logging import play.api.mvc._ import javax.inject._ import scala.concurrent.{ExecutionContext, Future} class CustomAction @Inject() (parser: BodyParsers.Default)(implicit ec: ExecutionContext) extends Actio..