Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation for requireThatR and paramR #59

Open
bryce-anderson opened this issue Feb 18, 2015 · 2 comments
Open

Documentation for requireThatR and paramR #59

bryce-anderson opened this issue Feb 18, 2015 · 2 comments

Comments

@bryce-anderson
Copy link
Member

The two aforementioned methods allow one to define a route requirement that can return an arbitrary response. An example is thus:

val requireCookie = requireThatR(headers.Cookie){ cookie =>
    cookie.values.toList.find(c => c.name == "Foo" && c.content == "bar") match {
      case Some(_) => None   // Cookie found, good to go.
      case None => // Didn't find cookie
        Some(TemporaryRedirect(uri("/addcookie")))
    }
}

I'm not sure the semantics are perfect: its counter intuitive to interpret a None as a 'success'.

@aryairani
Copy link

One alternative would be Failure \/ Unit, but maybe a custom Pass/Fail extends RequirementResult type (or something) would be clearer

@bryce-anderson
Copy link
Member Author

Wow, this has been on the shelf for a long time hasn't it? Any strong feelings on this issue? I'm slightly leaning toward a custom Pass / Fail but the available unambiguous names in the domain are pretty sparse... Maybe Continue and Abort(msg)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants