ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • Filter
    scala/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.
     */
    @Singleton
    class ExampleFilter @Inject()(implicit ec: ExecutionContext) extends EssentialFilter {
      override def apply(next: EssentialAction) = EssentialAction { request =>
        next(request).map { result =>
          result.withHeaders("X-ExampleFilter" -> "foo")
        }
      }
    }

     

    'scala > playframework' 카테고리의 다른 글

    ScalaTest  (0) 2023.02.19
    Using ScalikeJDBC  (0) 2023.02.19
    Logging MDC  (0) 2023.02.19
    Deploy  (0) 2023.02.19
    Action composition  (0) 2023.02.19

    댓글

Designed by Tistory.