class AuthenticatedBuilder[U] extends ActionBuilder[[A]AuthenticatedRequest[A, U], AnyContent]
- Alphabetic
- By Inheritance
- AuthenticatedBuilder
- ActionBuilder
- ActionFunction
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Instance Constructors
- new AuthenticatedBuilder(userinfo: (RequestHeader) => Option[U], defaultParser: [AnyContent], onUnauthorized: () => Result = implicit request => Unauthorized(views.html.defaultpages.unauthorized()))(implicit executionContext: ExecutionContext)
- userinfo
The function that looks up the user info.
- onUnauthorized
The function to get the result for when no authenticated user can be found.
Value Members
- def andThen[Q[_]](other: [[A]AuthenticatedRequest[A, U], Q]): ActionBuilder[Q, AnyContent]
Compose this ActionFunction with another, with this one applied first.
Compose this ActionFunction with another, with this one applied first.
- other
ActionFunction with which to compose
- returns
The new ActionFunction
- Definition Classes
- → ActionFunction
- final def apply(block: => Result): [AnyContent]
Constructs an
Action
with default content, and no request parameter.Constructs an
Action
with default content, and no request parameter.For example:
val hello = Action { Ok("Hello!") }
- block
the action code
- returns
an action
- Definition Classes
- ActionBuilder
- final def apply(block: ([AnyContent, U]) => Result): [AnyContent]
Constructs an
Action
with default content.Constructs an
Action
with default content.For example:
val echo = Action { request => Ok("Got request [" + request + "]") }
- block
the action code
- returns
an action
- Definition Classes
- ActionBuilder
- final def apply[A](bodyParser: BodyParser[A]): [[A]AuthenticatedRequest[A, U], A]
Constructs an with the given BodyParser.
Constructs an with the given BodyParser. The result can then be applied directly to a block.
For example:
val echo = Action(parse.anyContent) { request => Ok("Got request [" + request + "]") }
- A
the type of the request body
- bodyParser
the
BodyParser
to use to parse the request body- returns
an action
- Definition Classes
- ActionBuilder
- final def async[A](bodyParser: BodyParser[A])(block: (AuthenticatedRequest[A, U]) => Future[Result]): Action[A]
Constructs an
Action
with the given BodyParser that returns a future of a result.Constructs an
Action
with the given BodyParser that returns a future of a result.For example:
val hello = Action.async(parse.anyContent) { request => ws.url(request.getQueryString("url").get).get().map { r => if (r.status == 200) Ok("The website is up") else NotFound("The website is down") } }
- block
the action code
- returns
an action
- Definition Classes
- ActionBuilder
- final def async(block: ([AnyContent, U]) => Future[Result]): [AnyContent]
Constructs an
Action
that returns a future of a result, with default content.Constructs an
Action
that returns a future of a result, with default content.For example:
val hello = Action.async { request => ws.url(request.getQueryString("url").get).get().map { r => if (r.status == 200) Ok("The website is up") else NotFound("The website is down") } }
- block
the action code
- returns
an action
- Definition Classes
- ActionBuilder
- final def async(block: => Future[Result]): [AnyContent]
Constructs an
Action
that returns a future of a result, with default content, and no request parameter.Constructs an
Action
that returns a future of a result, with default content, and no request parameter.For example:
val hello = Action.async { ws.url("http://www.playframework.com").get().map { r => if (r.status == 200) Ok("The website is up") else NotFound("The website is down") } }
- block
the action code
- returns
an action
- Definition Classes
- ActionBuilder
- def authenticate[A](request: Request[A], block: (AuthenticatedRequest[A, U]) => Future[Result]): Future[Result]
Authenticate the given block.
- def compose[B](other: [Request, B]): [[A]AuthenticatedRequest[A, U], B]
- Definition Classes
- ActionFunction
- def compose[Q[_]](other: ActionFunction[Q, Request]): ActionFunction[Q, [A]AuthenticatedRequest[A, U]]
Compose another ActionFunction with this one, with this one applied last.
Compose another ActionFunction with this one, with this one applied last.
- other
ActionFunction with which to compose
- returns
The new ActionFunction
- Definition Classes
- ActionFunction
- implicit val executionContext: ExecutionContext
- returns
The execution context to run the request in.
- Definition Classes
- → ActionFunction
- def invokeBlock[A](request: Request[A], block: (AuthenticatedRequest[A, U]) => Future[Result]): Future[Result]
Invoke the block.
Invoke the block. This is the main method that an ActionBuilder has to implement, at this stage it can wrap it in any other actions, modify the request object or potentially use a different class to represent the request.
- request
The request
- block
The block of code to invoke
- returns
A future of the result
- Definition Classes
- → ActionFunction
- lazy val parser: [AnyContent]
- returns
The BodyParser to be used by this ActionBuilder if no other is specified
- Definition Classes
- → ActionBuilder
An authenticated action builder.
This can be used to create an action builder, like so:
You can then use the authenticated builder with other action builders, i.e. to use a messagesApi with authentication, you can add: