Packages

object ContentEncoder

Library of built-in content encoders.

This provides content encoder functions for the common scala types, and implicit encoder configured with a set of sensible default.

The implicitly provided encoders are chosen by the compiler and cannot be explicitly configured.

For example, this code:

val response = Ok("Hello, world!")

will generate an HTTP response body by encoding the provided string using the UTF-8 charset.

If you want to configure the content encoder, you can just pass it yourself instead of relying on implicit resolution:

val response = Ok("Hello, world!")(text(codec = Codec("us-ascii")))
Source
Content.scala
Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. ContentEncoder
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

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. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. implicit val binary: ContentEncoder[Array[Byte]]

    Encode Array[Byte] binary data.

  6. implicit val byteBuffer: ContentEncoder[ByteBuffer]

    Encode ByteBuffer binary data.

  7. def clone(): AnyRef
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @native() @throws( ... )
  8. implicit def defaultFile: ContentEncoder[File]

    Default text encoder, using 16KB chunks.

  9. implicit val defaultText: ContentEncoder[CharSequence]

    Default text encoder, using UTF-8 as charset.

  10. implicit val emptyContent: ContentEncoder[Unit]

    Encode Unit values as an empty content.

  11. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  12. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  13. def file(chunkSize: Int = 16 * 1024): ContentEncoder[File]

    Create a content encoder for java.io.File.

    Create a content encoder for java.io.File.

    chunkSize

    the size of chunks that will be produced in the content stream. Default to 16KB.

    returns

    an encoder for java.io.File.

  14. def finalize(): Unit
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  15. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  16. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  17. implicit val identity: ContentEncoder[Content]

    Pass-through encoder for Content values.

  18. def inputStream(chunkSize: Int = 16 * 1024): ContentEncoder[InputStream]

    Create a content encoder for java blocking java.io.InputStream.

    Create a content encoder for java blocking java.io.InputStream.

    Note that the inputStream is read lazily and is not buffered in memory. Therefore the content length is not known and no corresponding HTTP header is produced.

    chunkSize

    the size of chunks that will be produced in the content stream. Default to 16KB.

    returns

    an encoder for java.io.InputStream.

  19. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  20. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  21. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  22. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  23. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  24. def text(codec: Codec = Codec.UTF8): ContentEncoder[CharSequence]

    Create text content encoder using the provided charset.

    Create text content encoder using the provided charset.

    codec

    the codec to use to code the string as binary.

    returns

    an encoder for java.lang.Charsequence.

  25. def toString(): String
    Definition Classes
    AnyRef → Any
  26. implicit val urlEncoded: ContentEncoder[Map[String, Seq[String]]]

    Encode url-encoded-form-data from a Map[String,Seq[String]] value.

    Encode url-encoded-form-data from a Map[String,Seq[String]] value. See https://www.w3.org/TR/html5/forms.html#url-encoded-form-data.

  27. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  28. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  29. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @throws( ... )

Inherited from AnyRef

Inherited from Any

Ungrouped