Quantcast
Channel: MarsHut
Viewing all articles
Browse latest Browse all 6551

Action interception with the new Promise structure

$
0
0
I currently have a custom HTTP filter that extends Action.Simple. It's
purpose to to intercept incoming requests and run a few checks on them
(CSRF verification, Session validity, etc.). As long as the checks pass,
then I delegate the request to the original target controller like this:

public class HttpFilter extends Action.Simple {

...some custom stuff...

@Override
public Result call(Http.Context ctx) throws Throwable {
// Perform a few checks based on the active filters

if ( valid ) {
result = delegate.call(ctx);

return result;

Now that the return type for Action.Simple.call() has changed however, this
seems to be problematic. The call() return type is Promise<Result>. If I
override call() and then delegate that call internally, I end up having
nested Promises. This seems strange to me. Is it problematic to have
nested Promises like this? Is there a better way to do this type of
interception/delegation with the new Results types?

Kyle

Viewing all articles
Browse latest Browse all 6551

Trending Articles