Take the 2-minute tour ×

Suppose I have this action structure:

def checkAccess(request: Request[AnyContent]) {
    if (shouldntGetAccess()) {
        // I want to return 404 and stop execution here

def index = Action { implicit request =>


How do I decide to return a 404 page from checkAccess() and stop execution? This was achieved in Play 1 with simply calling notFound(), but doesn't seem to behave the same in Play 2.

Could this be achieved by having checkAccess() throw some exception, and adding a filter to capture it and render the correct response? If you code provide a code sample, that would be great.

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted
def checkAccess(f: Request[AnyContent] => Result) = Action{ request => 

def index = checkAccess{ request => 
share|improve this answer
Hmm, interesting functional approach. –  ripper234 Mar 4 '13 at 10:14
add comment

Your Answer


