Packages

  • package root
    Definition Classes
    root
  • package play

    Play framework.

    Play framework.

    Play

    http://www.playframework.com

    Definition Classes
    root
  • package api

    Contains the public API for Scala developers.

    Contains the public API for Scala developers.

    Read configuration
    val poolSize = configuration.getInt("engine.pool.size")
    Use the logger
    Logger.info("Hello!")
    Define a Plugin
    class MyPlugin(app: Application) extends Plugin
    Create adhoc applications (for testing)
    val application = Application(new File("."), this.getClass.getClassloader, None, Play.Mode.DEV)
    Definition Classes
    play
  • package mvc

    Contains the Controller/Action/Result API to handle HTTP requests.

    Contains the Controller/Action/Result API to handle HTTP requests.

    For example, a typical controller:

    class HomeController @Inject() (val controllerComponents: ControllerComponents) extends BaseController {
    
      def index = Action {
        Ok("It works!")
      }
    
    }
    Definition Classes
    api
  • trait Results extends AnyRef

    Helper utilities to generate results.

    Helper utilities to generate results.

    Definition Classes
    mvc
  • Status

class Status extends Result

Generates default Result from a content type, headers and content.

Source
Results.scala
Linear Supertypes
Result, Serializable, Product, Equals, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Status
  2. Result
  3. Serializable
  4. Product
  5. Equals
  6. AnyRef
  7. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Instance Constructors

  1. new Status(status: Int)

    status

    the HTTP response status, e.g ‘200 OK’

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##: Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. 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.

    Definition Classes
    Result
  5. 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.

    Definition Classes
    Result
  6. 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.

    Definition Classes
    Result
  7. 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.

    Definition Classes
    Result
  8. 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.

    Definition Classes
    Result
  9. 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.

    Definition Classes
    Result
  10. def apply[C](content: C)(implicit writeable: Writeable[C]): Result

    Set the result's content.

    Set the result's content.

    content

    The content to send.

  11. 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

    Definition Classes
    Result
  12. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  13. def asJava: mvc.Result

    Convert this result to a Java result.

    Convert this result to a Java result.

    Definition Classes
    Result
  14. val attrs: TypedMap
    Definition Classes
    Result
  15. 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.

    Definition Classes
    Result
  16. val body: HttpEntity
    Definition Classes
    Result
  17. def chunked[C](content: Source[C, _], inline: Boolean, fileName: Option[String])(implicit writeable: Writeable[C], fileMimeTypes: FileMimeTypes): Result

    Feed the content as the response, using chunked transfer encoding.

    Feed the content as the response, using chunked transfer encoding.

    Chunked transfer encoding is only supported for HTTP 1.1 clients. If the client is an HTTP 1.0 client, Play will instead return a 505 error code.

    Chunked encoding allows the server to send a response where the content length is not known, or for potentially infinite streams, while still allowing the connection to be kept alive and reused for the next request.

    content

    Source providing the content to stream.

    inline

    If the content should be rendered inline or as attachment.

    fileName

    Function to retrieve the file name rendered in the Content-Disposition header. By default the name of the file is used. The response will also automatically include the MIME type in the Content-Type header deducing it from this file name if the implicit fileMimeTypes includes it or fallback to the content-type of the implicit writeable if unknown.

  18. def chunked[C](content: Source[C, _], contentType: Option[String] = None)(implicit writeable: Writeable[C]): Result

    Feed the content as the response, using chunked transfer encoding.

    Feed the content as the response, using chunked transfer encoding.

    Chunked transfer encoding is only supported for HTTP 1.1 clients. If the client is an HTTP 1.0 client, Play will instead return a 505 error code.

    Chunked encoding allows the server to send a response where the content length is not known, or for potentially infinite streams, while still allowing the connection to be kept alive and reused for the next request.

    content

    Source providing the content to stream.

    contentType

    an optional content type.

  19. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @HotSpotIntrinsicCandidate() @native()
  20. 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

    Definition Classes
    Result
  21. 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

    Definition Classes
    Result
  22. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  23. 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

    Definition Classes
    Result
  24. 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

    Definition Classes
    Result
  25. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @HotSpotIntrinsicCandidate() @native()
  26. val header: ResponseHeader
    Definition Classes
    Result
  27. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  28. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  29. val newCookies: Seq[Cookie]
    Definition Classes
    Result
  30. val newFlash: Option[Flash]
    Definition Classes
    Result
  31. val newSession: Option[Session]
    Definition Classes
    Result
  32. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @HotSpotIntrinsicCandidate() @native()
  33. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @HotSpotIntrinsicCandidate() @native()
  34. def productElementNames: Iterator[String]
    Definition Classes
    Product
  35. 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.

    Definition Classes
    Result
  36. 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.

    Definition Classes
    Result
  37. def sendEntity(entity: HttpEntity, inline: Boolean, fileName: Option[String])(implicit fileMimeTypes: FileMimeTypes): Result

    Send an HTTP entity with this status.

    Send an HTTP entity with this status.

    entity

    The entity to send.

    inline

    If the content should be rendered inline or as attachment.

    fileName

    Function to retrieve the file name rendered in the Content-Disposition header. By default the name of the file is used. The response will also automatically include the MIME type in the Content-Type header deducing it from this file name if the implicit fileMimeTypes includes it or fallback to application/octet-stream if unknown.

  38. def sendEntity(entity: HttpEntity): Result

    Send an HTTP entity with this status.

    Send an HTTP entity with this status.

    entity

    The entity to send.

  39. def sendFile(content: File, inline: Boolean = true, fileName: (File) => Option[String] = Option(_).map(_.getName), onClose: () => Unit = () => ())(implicit ec: ExecutionContext, fileMimeTypes: FileMimeTypes): Result

    Send a file.

    Send a file.

    content

    The file to send.

    inline

    Use Content-Disposition inline or attachment.

    fileName

    Function to retrieve the file name rendered in the Content-Disposition header. By default the name of the file is used. The response will also automatically include the MIME type in the Content-Type header deducing it from this file name if the implicit fileMimeTypes includes it or fallback to application/octet-stream if unknown.

    onClose

    Useful in order to perform cleanup operations (e.g. deleting a temporary file generated for a download).

  40. def sendPath(content: Path, inline: Boolean = true, fileName: (Path) => Option[String] = Option(_).map(_.getFileName.toString), onClose: () => Unit = () => ())(implicit ec: ExecutionContext, fileMimeTypes: FileMimeTypes): Result

    Send a path.

    Send a path.

    content

    The path to send.

    inline

    Use Content-Disposition inline or attachment.

    fileName

    Function to retrieve the file name rendered in the Content-Disposition header. By default the name of the file is used. The response will also automatically include the MIME type in the Content-Type header deducing it from this file name if the implicit fileMimeTypes includes it or fallback to application/octet-stream if unknown.

    onClose

    Useful in order to perform cleanup operations (e.g. deleting a temporary file generated for a download).

  41. def sendResource(resource: String, classLoader: ClassLoader = Results.getClass.getClassLoader, inline: Boolean = true, fileName: (String) => Option[String] = Option(_).map(_.split('/').last), onClose: () => Unit = () => ())(implicit ec: ExecutionContext, fileMimeTypes: FileMimeTypes): Result

    Send the given resource from the given classloader.

    Send the given resource from the given classloader.

    resource

    The path of the resource to load.

    classLoader

    The classloader to load it from, defaults to the classloader for this class.

    inline

    Whether it should be served as an inline file, or as an attachment.

    fileName

    Function to retrieve the file name rendered in the Content-Disposition header. By default the name of the file is used. The response will also automatically include the MIME type in the Content-Type header deducing it from this file name if the implicit fileMimeTypes includes it or fallback to application/octet-stream if unknown.

    onClose

    Useful in order to perform cleanup operations (e.g. deleting a temporary file generated for a download).

  42. 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.

    Definition Classes
    Result
  43. def streamed[C](content: Source[C, _], contentLength: Option[Long], inline: Boolean, fileName: Option[String])(implicit writeable: Writeable[C], fileMimeTypes: FileMimeTypes): Result

    Feed the content as the response, using a streamed entity.

    Feed the content as the response, using a streamed entity.

    It will use the given Content-Type, but if is not present, then it fallsback to use the Writeable contentType.

    content

    Source providing the content to stream.

    contentLength

    an optional content length.

    inline

    If the content should be rendered inline or as attachment.

    fileName

    Function to retrieve the file name rendered in the Content-Disposition header. By default the name of the file is used. The response will also automatically include the MIME type in the Content-Type header deducing it from this file name if the implicit fileMimeTypes includes it or fallback to the content-type of the implicit writeable if unknown.

  44. def streamed[C](content: Source[C, _], contentLength: Option[Long], contentType: Option[String] = None)(implicit writeable: Writeable[C]): Result

    Feed the content as the response, using a streamed entity.

    Feed the content as the response, using a streamed entity.

    It will use the given Content-Type, but if is not present, then it fallsback to use the Writeable contentType.

    content

    Source providing the content to stream.

    contentLength

    an optional content length.

    contentType

    an optional content type.

  45. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  46. def toString(): String
    Definition Classes
    Result → AnyRef → Any
  47. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  48. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  49. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  50. 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.

    Definition Classes
    Result
  51. 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

    Definition Classes
    Result
  52. 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.

    Definition Classes
    Result
  53. 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

    Definition Classes
    Result
  54. 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

    Definition Classes
    Result
  55. 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

    Definition Classes
    Result
  56. 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

    Definition Classes
    Result

Deprecated Value Members

  1. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable]) @Deprecated
    Deprecated

    (Since version 9)

Inherited from Result

Inherited from Serializable

Inherited from Product

Inherited from Equals

Inherited from AnyRef

Inherited from Any

Ungrouped