KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I understand that a method can have code like this: def m(p1:Int => Int) ... Which means this method takes a function p1 that returns an Int But while browsing the Play! framework code i found a trait with indecipherable methods: trait Secured { def username(request: RequestHeader) = request.session.get(Security.username) def onUnauthorized(request: RequestHeader) = Results.Redirect(routes.Auth.login) def withAuth(f: => String => Request[AnyContent] => Result) = { Security.Authenticated(username, onUnauthorized) { user => Action(request => f(user)(request)) } } /** * This method shows how you could wrap the withAuth method to also fetch your user * You will need to implement UserDAO.findOneByUsername */ def withUser(f: User => Request[AnyContent] => Result) = withAuth { username => implicit request => UserDAO.findOneByUsername(username).map { user => f(user)(request) }.getOrElse(onUnauthorized(request)) } } Play! Scala Security What does the f: User => Request[AnyContent] => Result mean? At first glance it looks like a method that returns a function r of type Request; r then returns a Result . Is this the right assumption?
Tags (comma-separated)
Save Edits
Cancel