jooby-project / jooby

The modular web framework for Java and Kotlin
https://jooby.io
Apache License 2.0
1.71k stars 197 forks source link

HttpServletRequest Attributes not available to jooby App #674

Closed andrenpaes closed 7 years ago

andrenpaes commented 7 years ago

We're trying to use jooby inside a Servlet container. In that setup, we also have a Filter that adds request scoped info into each request (using HttpServletRequest#setAttribute).

Unfortunately, there's no way to access those attributes using jooby's Request object. We have an ugly workaround in place, using a ThreadLocal and a jooby before filter:

before((req, rsp) -> {
    req.set("attributeName", someThreadLocal.get());
});

A possible solution, would be merging the HttpServletRequest#attributes into jooby's locals attributes. I have a patch that implements that, I can open a PR if it seems like a good enough solution. Let me know.

jknack commented 7 years ago

Sounds very good. Please send your patch.

Thanks