Closed GramDev1 closed 7 years ago
It does work, here is a simple request counter:
public class App extends Jooby {
@RequestScoped
public static class RScope {
private static AtomicInteger inc = new AtomicInteger(0);
private Integer id;
public RScope() {
this.id = inc.incrementAndGet();
}
@Override
public String toString() {
return id.toString();
}
}
{
use("*", "*", (req, rsp) -> {
req.set(RScope.class, new RScope());
});
get("/", req -> req.require(RScope.class));
}
public static void main(final String[] args) {
run(App::new, args);
}
}
Okay. In my case I have a route filter that sets some information, and then I get it in the next processor. With request attributes it works, but not with request scoped.
did you get an error? Post an example to reproduce the problem.
Thanks
Alright! I managed to fix it by unbinding the class. However, the java docs are a bit confusing on this matter, specifically here: http://jooby.org/apidocs/org/jooby/scope/RequestScoped.html . May want to clear that up. Great framework btw!
Glad you figure it out. Going to clear/update the javadoc.
Thank you and if you like it please don't forget to star/follow the project.
Hi, If I make a class request scoped, set it via request#set(Class,Object) will I be able to get it via request#require? Currently that does not work for me, or has this feature been implemented?