title: Access Request Body in essential filter Play Framework 2
body: <p>I am new to Scala.
  As mentioned in play framework official documentation in <a href="https://www.playframework.com/documentation/2.3.x/ScalaHttpFilters" rel="noreferrer">https://www.playframework.com/documentation/2.3.x/ScalaHttpFilters</a> :</p>
  
  <blockquote>
    <p>Play provides a lower level filter API called EssentialFilter which
    gives you full access to the body of the request.</p>
  </blockquote>
  
  <p>but there is not any method to accessing request body in <code>requestHeader</code> object.</p>
  
  <pre><code>import play.api.Logger
  import play.api.mvc._
  import play.api.libs.concurrent.Execution.Implicits.defaultContext
  
  object LoggingFilter extends EssentialFilter {
    def apply(nextFilter: EssentialAction) = new EssentialAction {
      def apply(requestHeader: RequestHeader) = {
        val startTime = System.currentTimeMillis
        nextFilter(requestHeader).map { result =&gt;
          val endTime = System.currentTimeMillis
          val requestTime = endTime - startTime
          Logger.info(s"${requestHeader.method} ${requestHeader.uri}" +
            s" took ${requestTime}ms and returned ${result.header.status}")
          result.withHeaders("Request-Time" -&gt; requestTime.toString)
        }
      }
    }
  }
  </code></pre>