HttpIncomingMessage
Common model for incoming HTTP messages.
HttpIncomingMessage is used by server requests and client responses to
expose headers, an optional remote address, and body accessors. This module
provides decoders for JSON bodies, URL-encoded bodies, and headers, plus the
shared body-size setting and inspection helper used by request and response
implementations.
Converting
Guards
isHttpIncomingMessage
Returns true when a value is an HttpIncomingMessage.
Signature
declare function isHttpIncomingMessage(u: unknown): u is HttpIncomingMessage<unknown>Models
HttpIncomingMessage interface
Common model for incoming HTTP messages, with headers, remote address, and effectful body accessors.
Signature
interface HttpIncomingMessage<E = unknown> extends Inspectable { readonly "~effect/http/HttpIncomingMessage": "~effect/http/HttpIncomingMessage"; readonly arrayBuffer: Effect<ArrayBuffer, E>; readonly headers: Headers; readonly json: Effect<Json, E>; readonly remoteAddress: Option<string>; readonly stream: Stream<Uint8Array<ArrayBufferLike>, E>; readonly text: Effect<string, E>; readonly urlParamsBody: Effect<UrlParams, E>;}JsonOptions interface
Options for parsing an incoming HTTP message body as JSON.
Signature
interface JsonOptions { readonly reviver?: (this: any, key: string, value: any) => any;}References
MaxBodySize
Context reference for the optional maximum size allowed when reading an incoming message body.
Signature
declare const MaxBodySize: Reference<Size | undefined>Schemas
schemaBodyJson
Creates a decoder that reads an incoming message's JSON body and decodes it with the supplied schema.
Signature
declare function schemaBodyJson<S extends Constraint>(schema: S, options?: ParseOptions & JsonOptions): <E>(self: HttpIncomingMessage<E>) => Effect<S["Type"], SchemaError | E, S["DecodingServices"]>schemaBodyUrlParams
Creates a decoder that reads an incoming message's URL-encoded body parameters and decodes them with the supplied schema.
Signature
declare function schemaBodyUrlParams<A, I extends Readonly<Record<string, string | readonly Array<string> | undefined>>, RD>(schema: ConstraintCodec<A, I, RD, unknown>, options?: ParseOptions): <E>(self: HttpIncomingMessage<E>) => Effect<A, SchemaError | E, RD>schemaHeaders
Creates a decoder that validates and decodes an incoming message's headers with the supplied schema.
Signature
declare function schemaHeaders<A, I extends Readonly<Record<string, string | undefined>>, RD>(schema: ConstraintCodec<A, I, RD, unknown>, options?: ParseOptions): <E>(self: HttpIncomingMessage<E>) => Effect<A, SchemaError, RD>