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
- Alphabetic
- By Inheritance
- ContentEncoder
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
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
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
implicit
val
binary: ContentEncoder[Array[Byte]]
Encode
Array[Byte]
binary data. -
implicit
val
byteBuffer: ContentEncoder[ByteBuffer]
Encode
ByteBuffer
binary data. -
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )
-
implicit
def
defaultFile: ContentEncoder[File]
Default text encoder, using
16KB
chunks. -
implicit
val
defaultText: ContentEncoder[CharSequence]
Default text encoder, using
UTF-8
as charset. -
implicit
val
emptyContent: ContentEncoder[Unit]
Encode
Unit
values as an empty content. -
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
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
.
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
implicit
val
identity: ContentEncoder[Content]
Pass-through encoder for Content values.
-
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
.
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
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
.
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
implicit
val
urlEncoded: ContentEncoder[Map[String, Seq[String]]]
Encode
url-encoded-form-data
from aMap[String,Seq[String]]
value.Encode
url-encoded-form-data
from aMap[String,Seq[String]]
value. See https://www.w3.org/TR/html5/forms.html#url-encoded-form-data. -
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )