case class Result(header: ResponseHeader, body: HttpEntity, newSession: Option[Session] = None, newFlash: Option[Flash] = None, newCookies: Seq[Cookie] = Seq.empty, attrs: TypedMap = TypedMap.empty) extends Product with Serializable
A simple result, which defines the response header and a body ready to send to the client.
- header
the response header, which contains status code and HTTP headers
- body
the response body
- Source
- Results.scala
- Alphabetic
- By Inheritance
- Result
- Serializable
- Product
- Equals
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Instance Constructors
- new Result(header: ResponseHeader, body: HttpEntity, newSession: Option[Session] = None, newFlash: Option[Flash] = None, newCookies: Seq[Cookie] = Seq.empty, attrs: TypedMap = TypedMap.empty)
- header
the response header, which contains status code and HTTP headers
- body
the response body
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- def addAttr[A](key: TypedKey[A], value: A): Result
Create a new versions of this object with the given attribute attached to it.
Create a new versions of this object with the given attribute attached to it.
- A
The type of value.
- key
The new attribute key.
- value
The attribute value.
- returns
The new version of this object with the new attribute.
- def addAttrs(entries: TypedEntry[_]*): Result
Create a new versions of this object with the given attributes attached to it.
Create a new versions of this object with the given attributes attached to it.
- entries
The new attributes.
- returns
The new version of this object with the new attributes.
- def addAttrs(e1: TypedEntry[_], e2: TypedEntry[_], e3: TypedEntry[_]): Result
Create a new versions of this object with the given attributes attached to it.
Create a new versions of this object with the given attributes attached to it.
- e1
The first new attribute.
- e2
The second new attribute.
- e3
The third new attribute.
- returns
The new version of this object with the new attributes.
- def addAttrs(e1: TypedEntry[_], e2: TypedEntry[_]): Result
Create a new versions of this object with the given attributes attached to it.
Create a new versions of this object with the given attributes attached to it.
- e1
The first new attribute.
- e2
The second new attribute.
- returns
The new version of this object with the new attributes.
- def addAttrs(e1: TypedEntry[_]): Result
Create a new versions of this object with the given attribute attached to it.
Create a new versions of this object with the given attribute attached to it.
- e1
The new attribute.
- returns
The new version of this object with the new attribute.
- def addingToSession(values: (String, String)*)(implicit request: RequestHeader): Result
Example:
Example:
Ok.addingToSession("foo" -> "bar").addingToSession("baz" -> "bah")
- values
(key -> value) pairs to add to this result’s session
- request
Current request
- returns
A copy of this result with
values
added to its session scope.
- def as(contentType: String): Result
Changes the result content type.
Changes the result content type.
For example:
Ok("<text>Hello world</text>").as("application/xml")
- contentType
the new content type.
- returns
the new result
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def asJava: mvc.Result
Convert this result to a Java result.
- val attrs: TypedMap
- def bakeCookies(cookieHeaderEncoding: CookieHeaderEncoding = new DefaultCookieHeaderEncoding(), sessionBaker: CookieBaker[Session] = new DefaultSessionCookieBaker(), flashBaker: CookieBaker[Flash] = new DefaultFlashCookieBaker(), requestHasFlash: Boolean = false): Result
Encode the cookies into the Set-Cookie header.
Encode the cookies into the Set-Cookie header. The session is always baked first, followed by the flash cookie, followed by all the other cookies in order.
- val body: HttpEntity
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @HotSpotIntrinsicCandidate() @native()
- def discardingCookies(cookies: DiscardingCookie*): Result
Discards cookies along this result.
Discards cookies along this result.
For example:
Redirect(routes.Application.index()).discardingCookies(DiscardingCookie("theme"))
- cookies
the cookies to discard along to this result
- returns
the new result
- def discardingHeader(name: String): Result
Discards headers to this result.
Discards headers to this result.
For example:
Ok("Hello world").discardingHeader(ETAG)
- name
the header to discard from this result.
- returns
the new result
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def flashing(values: (String, String)*): Result
Adds values to the flash scope for this result.
Adds values to the flash scope for this result.
For example:
Redirect(routes.Application.index()).flashing("success" -> "Done!")
- values
the flash values to set with this result
- returns
the new result
- def flashing(flash: Flash): Result
Adds values to the flash scope for this result.
Adds values to the flash scope for this result.
For example:
Redirect(routes.Application.index()).flashing(flash + ("success" -> "Done!"))
- flash
the flash scope to set with this result
- returns
the new result
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @HotSpotIntrinsicCandidate() @native()
- val header: ResponseHeader
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- val newCookies: Seq[Cookie]
- val newFlash: Option[Flash]
- val newSession: Option[Session]
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @HotSpotIntrinsicCandidate() @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @HotSpotIntrinsicCandidate() @native()
- def productElementNames: Iterator[String]
- Definition Classes
- Product
- def removeAttr(key: TypedKey[_]): Result
Create a new versions of this object with the given attribute removed.
Create a new versions of this object with the given attribute removed.
- key
The key of the attribute to remove.
- returns
The new version of this object with the attribute removed.
- def removingFromSession(keys: String*)(implicit request: RequestHeader): Result
Example:
Example:
Ok.removingFromSession("foo")
- keys
Keys to remove from session
- request
Current request
- returns
A copy of this result with
keys
removed from its session scope.
- def session(implicit request: RequestHeader): Session
- request
Current request
- returns
The session carried by this result. Reads the request’s session if this result does not modify the session.
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- Result → AnyRef → Any
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- def withAttrs(newAttrs: TypedMap): Result
Create a new version of this object with the given attributes attached to it.
Create a new version of this object with the given attributes attached to it. This replaces any existing attributes.
- newAttrs
The new attributes to add.
- returns
The new version of this object with the attributes attached.
- def withCookies(cookies: Cookie*): Result
Adds cookies to this result.
Adds cookies to this result. If the result already contains cookies then cookies with the same name in the new list will override existing ones.
For example:
Redirect(routes.Application.index()).withCookies(Cookie("theme", "blue"))
- cookies
the cookies to add to this result
- returns
the new result
- def withDateHeaders(headers: (String, ZonedDateTime)*): Result
Add a header with a DateTime formatted using the default http date format
Add a header with a DateTime formatted using the default http date format
- headers
the headers with a DateTime to add to this result.
- returns
the new result.
- def withHeaders(headers: (String, String)*): Result
Adds headers to this result.
Adds headers to this result.
For example:
Ok("Hello world").withHeaders(ETAG -> "0")
- headers
the headers to add to this result.
- returns
the new result
- def withNewSession: Result
Discards the existing session for this result.
Discards the existing session for this result.
For example:
Redirect(routes.Application.index()).withNewSession
- returns
the new result
- def withSession(session: (String, String)*): Result
Sets a new session for this result, discarding the existing session.
Sets a new session for this result, discarding the existing session.
For example:
Redirect(routes.Application.index()).withSession("saidHello" -> "yes")
- session
the session to set with this result
- returns
the new result
- def withSession(session: Session): Result
Sets a new session for this result.
Sets a new session for this result.
For example:
Redirect(routes.Application.index()).withSession(session + ("saidHello" -> "true"))
- session
the session to set with this result
- returns
the new result
Deprecated Value Members
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable]) @Deprecated
- Deprecated
(Since version 9)