Overall:
My question is about adding a Servlet Filter to Play framework project to be invoked before routing.
Versions:
More Info:
Issue:
AFAIK there are no servlet interceptors in Play 1.x You can use the @Before annotation to solve some of your problems. But @Before is not a fully qualified alternative to an interceptor.
A manual (and a bit low level) approach can be adding your interceptor to play pipeline. Play has a configuration play.netty.pipeline
which defaults to :
#play.netty.pipeline = play.server.FlashPolicyHandler,org.jboss.netty.handler.codec.http.HttpRequestDecoder,play.server.StreamChunkAggregator,org.jboss.netty.handler.codec.http.HttpResponseEncoder,org.jboss.netty.handler.stream.ChunkedWriteHandler,play.server.PlayHandler
You can modify the pipeline and add your custom handler before the last element (play.server.PlayHandler
) in the list.