HttpIncomingMessage unstable
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
unstableReturns true when a value is an HttpIncomingMessage.
Signature
declare function isHttpIncomingMessage(u: unknown): u is HttpIncomingMessage<unknown>Models
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>;}Options for parsing an incoming HTTP message body as JSON.
Signature
interface JsonOptions { readonly reviver?: (this: any, key: string, value: any) => any;}References
MaxBodySize
unstableContext reference for the optional maximum size allowed when reading an incoming message body.
Signature
declare const MaxBodySize: Reference<ByteSize | undefined>Schemas
schemaBodyJson
unstableCreates 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
unstableCreates 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
unstableCreates 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>