Body

zio.http.Body
See theBody companion trait
object Body

Attributes

Companion
trait
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
Body.type

Members list

Type members

Classlikes

final case class ContentType(mediaType: MediaType, boundary: Option[Boundary] = ..., charset: Option[Charset] = ...)

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object ContentType

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type

Value members

Concrete methods

def from[A](a: A)(implicit codec: BinaryCodec[A], trace: Trace): Body

Constructs a zio.http.Body from a value based on a zio-schema zio.schema.codec.BinaryCodec.
Example for json:

Constructs a zio.http.Body from a value based on a zio-schema zio.schema.codec.BinaryCodec.
Example for json:

import zio.schema.codec.JsonCodec._
case class Person(name: String, age: Int)
implicit val schema: Schema[Person] = DeriveSchema.gen[Person]
val person = Person("John", 42)
val body = Body.from(person)

Attributes

def fromArray(data: Array[Byte]): Body

Constructs a zio.http.Body from an array of bytes.

Constructs a zio.http.Body from an array of bytes.

WARNING: The array must not be mutated after creating the body.

Attributes

def fromCharSequence(charSequence: CharSequence, charset: Charset = ...): Body

Constructs a zio.http.Body from the contents of a file.

Constructs a zio.http.Body from the contents of a file.

Attributes

def fromCharSequenceStream(stream: ZStream[Any, Throwable, CharSequence], contentLength: Long, charset: Charset = ...)(implicit trace: Trace): Body

Constructs a zio.http.Body from a stream of text with known length, using the specified character set, which defaults to the HTTP character set.

Constructs a zio.http.Body from a stream of text with known length, using the specified character set, which defaults to the HTTP character set.

Attributes

def fromCharSequenceStreamChunked(stream: ZStream[Any, Throwable, CharSequence], charset: Charset = ...)(implicit trace: Trace): Body

Constructs a zio.http.Body from a stream of text with unknown length using chunked transfer encoding, using the specified character set, which defaults to the HTTP character set.

Constructs a zio.http.Body from a stream of text with unknown length using chunked transfer encoding, using the specified character set, which defaults to the HTTP character set.

Attributes

def fromCharSequenceStreamChunkedEnv[R](stream: ZStream[R, Throwable, CharSequence], charset: Charset = ...)(implicit trace: Trace): RIO[R, Body]

Constructs a zio.http.Body from a stream of text with unknown length using chunked transfer encoding that depends on R, using the specified character set, which defaults to the HTTP character set.

Constructs a zio.http.Body from a stream of text with unknown length using chunked transfer encoding that depends on R, using the specified character set, which defaults to the HTTP character set.

Attributes

def fromCharSequenceStreamEnv[R](stream: ZStream[R, Throwable, CharSequence], contentLength: Long, charset: Charset = ...)(implicit trace: Trace): RIO[R, Body]

Constructs a zio.http.Body from a stream of text with known length that depends on R, using the specified character set, which defaults to the HTTP character set.

Constructs a zio.http.Body from a stream of text with known length that depends on R, using the specified character set, which defaults to the HTTP character set.

Attributes

def fromChunk(data: Chunk[Byte]): Body

Constructs a zio.http.Body from a chunk of bytes.

Constructs a zio.http.Body from a chunk of bytes.

Attributes

def fromChunk(data: Chunk[Byte], mediaType: MediaType): Body

Constructs a zio.http.Body from a chunk of bytes and sets the media type.

Constructs a zio.http.Body from a chunk of bytes and sets the media type.

Attributes

def fromChunk(data: Chunk[Byte], contentType: ContentType): Body
def fromFile(file: File, chunkSize: Int = ...)(implicit trace: Trace): ZIO[Any, Nothing, Body]

Constructs a zio.http.Body from the contents of a file.

Constructs a zio.http.Body from the contents of a file.

Attributes

def fromMultipartForm(form: Form, specificBoundary: Boundary)(implicit trace: Trace): Body

Constructs a zio.http.Body from from form data, using multipart encoding and the specified character set, which defaults to UTF-8.

Constructs a zio.http.Body from from form data, using multipart encoding and the specified character set, which defaults to UTF-8.

Attributes

def fromMultipartFormUUID(form: Form)(implicit trace: Trace): UIO[Body]

Constructs a zio.http.Body from from form data, using multipart encoding and the specified character set, which defaults to UTF-8. Utilizes a random boundary based on a UUID.

Constructs a zio.http.Body from from form data, using multipart encoding and the specified character set, which defaults to UTF-8. Utilizes a random boundary based on a UUID.

Attributes

def fromSocketApp(app: WebSocketApp[Any]): WebsocketBody
def fromStream(stream: ZStream[Any, Throwable, Byte], contentLength: Long): Body

Constructs a zio.http.Body from a stream of bytes with a known length.

Constructs a zio.http.Body from a stream of bytes with a known length.

Attributes

def fromStream[A](stream: ZStream[Any, Throwable, A])(implicit codec: BinaryCodec[A], trace: Trace): Body

Constructs a zio.http.Body from stream of values based on a zio-schema zio.schema.codec.BinaryCodec.

Constructs a zio.http.Body from stream of values based on a zio-schema zio.schema.codec.BinaryCodec.

Example for json:

import zio.schema.codec.JsonCodec._
case class Person(name: String, age: Int)
implicit val schema: Schema[Person] = DeriveSchema.gen[Person]
val persons = ZStream(Person("John", 42))
val body = Body.fromStream(persons)

Attributes

Constructs a zio.http.Body from a stream of bytes of unknown length, using chunked transfer encoding.

Constructs a zio.http.Body from a stream of bytes of unknown length, using chunked transfer encoding.

Attributes

def fromStreamChunkedEnv[R](stream: ZStream[R, Throwable, Byte])(implicit trace: Trace): RIO[R, Body]

Constructs a zio.http.Body from a stream of bytes of unknown length that depends on R, using chunked transfer encoding.

Constructs a zio.http.Body from a stream of bytes of unknown length that depends on R, using chunked transfer encoding.

Attributes

def fromStreamEnv[R](stream: ZStream[R, Throwable, Byte], contentLength: Long)(implicit trace: Trace): RIO[R, Body]

Constructs a zio.http.Body from a stream of bytes with a known length that depends on R.

Constructs a zio.http.Body from a stream of bytes with a known length that depends on R.

Attributes

def fromStreamEnv[A, R](stream: ZStream[R, Throwable, A])(implicit codec: BinaryCodec[A], trace: Trace): RIO[R, Body]

Constructs a zio.http.Body from stream of values based on a zio-schema zio.schema.codec.BinaryCodec and depends on R

Constructs a zio.http.Body from stream of values based on a zio-schema zio.schema.codec.BinaryCodec and depends on R

Attributes

def fromString(text: String, charset: Charset = ...): Body

Helper to create Body from String

Helper to create Body from String

Attributes

def fromURLEncodedForm(form: Form, charset: Charset = ...): Body

Constructs a zio.http.Body from form data using URL encoding and the default character set.

Constructs a zio.http.Body from form data using URL encoding and the default character set.

Attributes

def json[A](a: A)(implicit schema: Schema[A]): Body

Constructs a zio.http.Body from a value as JSON using zio-schema.

Constructs a zio.http.Body from a value as JSON using zio-schema.

Example:

import zio.schema.{DeriveSchema, Schema}
case class Person(name: String, age: Int)
implicit val schema: Schema[Person] = DeriveSchema.gen[Person]
val person = Person("John", 42)
val body = Body.json(person)

Attributes

def jsonCodec[A](a: A)(implicit encoder: JsonEncoder[A]): Body

Constructs a zio.http.Body from a value as JSON using zio-json.

Constructs a zio.http.Body from a value as JSON using zio-json.

Example:

import zio.json._
case class Person(name: String, age: Int)
implicit val encoder: JsonEncoder[Person] = DeriveJsonEncoder.gen[Person]
val person = Person("John", 42)
val body = Body.jsonZio(person)

Attributes

Concrete fields

val empty: Body

A body that contains no data.

A body that contains no data.

Attributes