.select(&quot;max_request_body_size&quot;).asOpt[Long],
        maxResponseBodySize = json.select(&quot;max_response_body_size&quot;).asOpt[Long],
      )
    } match {
      case Failure(e) =&gt; JsError(e.getMessage)
      case Success(e) =&gt; JsSuccess(e)
    }
    override def writes(o: BodyLengthLimiterConfig): JsValue = Json.obj(
      &quot;max_request_body_size&quot; -&gt; o.maxRequestBodySize,
      &quot;max_response_body_size&quot; -&gt; o.maxResponseBodySize
    )
  }
}

class BodyLengthLimiter