Last active
August 29, 2015 14:18
-
-
Save ivanmartinvalle/562a420a12f99aabb2c3 to your computer and use it in GitHub Desktop.
Play Framework Java Filter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import play.api.mvc.*; | |
import scala.Function1; | |
import scala.concurrent.Future; | |
import scala.runtime.AbstractFunction1; | |
public abstract class JavaFilter implements Filter { | |
@Override | |
public Future<Result> apply(Function1<RequestHeader, Future<Result>> nextFilter, RequestHeader requestHeader) { | |
return nextFilter | |
.apply(requestHeader) | |
.map(new AbstractFunction1<Result, Result>() { | |
@Override | |
public Result apply(Result currentResult) { | |
return Apply(currentResult, requestHeader); | |
} | |
}, | |
play.api.libs.concurrent.Execution.defaultContext()); | |
} | |
@Override | |
public EssentialAction apply(EssentialAction next) { | |
return Filter$class.apply(this, next); | |
} | |
public abstract Result Apply(Result currentResult, RequestHeader requestHeader); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment