Request/Response available in injector

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Request/Response available in injector

Neeraj
Hi All,

   In the process of porting an existing grails application to Ratpack, i have run into a couple scenarios where i require access to the 'Request' object.

Are the Request and Response objects available in the guice injector ? I have not been able to find any way to get a handle to the Request without considering some sort of custom guice 'request' scope.

e.g usecase : Using guice aop to intercept and decorate output of a Service call. In the interceptor I have need for access to the Request object.

Reply | Threaded
Open this post in threaded view
|

Re: Request/Response available in injector

Luke Daley
Administrator
Scope based proxies and state based AOP aren't practical in async environments. All such techniques rely on using thread local variables, which don't make sense in an async environment.

You have to explicitly pass the Context (or Request/Response) around.

This also makes code much more testable.