CSRF exception for Router

I’m using Play 2.8.x in Scala.

I’m looking for a way to allow an exception to a globally applied CSRF filter to all routes handled by a custom Router. Example routes file:

# the standard exception tag for singular routes does not work when applied to a router
->         /custom-router-path    routers.CustomRouterImpl

I’ve reviewed the APIs around Router, Routes, etc, but have not found anywhere this might be possible. As far as I can tell, the CSRF filter has already been applied by the time the RequestHeader is passed to the Router.routes partial function.

Is anyone able to help me understand if/where this might be possible?


Hi @dkichler, welcome to the community =D.

As far as i know the filters are applied before the request reach the gateway. Usually filters are used to make something to ALL requests. If you do not want to applied a given filter to a route maybe you just build an Action instead.