HttpIncomingMessage.ts
HttpIncomingMessage.ts overview
Section titled “HttpIncomingMessage.ts overview”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.
Since v4.0.0
Exports Grouped by Category
Section titled “Exports Grouped by Category”converting
Section titled “converting”inspect
Section titled “inspect”Builds an inspectable object for an incoming message, redacting headers and including a synchronously readable JSON or text body when available.
Signature
declare const inspect: <E>(self: HttpIncomingMessage<E>, that: object) => objectSince v4.0.0
guards
Section titled “guards”isHttpIncomingMessage
Section titled “isHttpIncomingMessage”Returns true when a value is an HttpIncomingMessage.
Signature
declare const isHttpIncomingMessage: (u: unknown) => u is HttpIncomingMessageSince v4.0.0
models
Section titled “models”HttpIncomingMessage (interface)
Section titled “HttpIncomingMessage (interface)”Common model for incoming HTTP messages, with headers, remote address, and effectful body accessors.
Signature
export interface HttpIncomingMessage<E = unknown> extends Inspectable.Inspectable { readonly [TypeId]: typeof TypeId readonly headers: Headers.Headers readonly remoteAddress: Option.Option<string> readonly json: Effect.Effect<Schema.Json, E> readonly text: Effect.Effect<string, E> readonly urlParamsBody: Effect.Effect<UrlParams.UrlParams, E> readonly arrayBuffer: Effect.Effect<ArrayBuffer, E> readonly stream: Stream.Stream<Uint8Array, E>}Since v4.0.0
references
Section titled “references”MaxBodySize
Section titled “MaxBodySize”Context reference for the optional maximum size allowed when reading an incoming message body.
Signature
declare const MaxBodySize: Context.Reference<FileSystem.Size | undefined>Since v4.0.0
schemas
Section titled “schemas”schemaBodyJson
Section titled “schemaBodyJson”Creates a decoder that reads an incoming message’s JSON body and decodes it with the supplied schema.
Signature
declare const schemaBodyJson: <S extends Schema.Constraint>( schema: S, options?: ParseOptions | undefined) => <E>(self: HttpIncomingMessage<E>) => Effect.Effect<S["Type"], E | Schema.SchemaError, S["DecodingServices"]>Since v4.0.0
schemaBodyUrlParams
Section titled “schemaBodyUrlParams”Creates a decoder that reads an incoming message’s URL-encoded body parameters and decodes them with the supplied schema.
Signature
declare const schemaBodyUrlParams: < A, I extends Readonly<Record<string, string | ReadonlyArray<string> | undefined>>, RD, RE>( schema: Schema.Codec<A, I, RD, RE>, options?: ParseOptions | undefined) => <E>(self: HttpIncomingMessage<E>) => Effect.Effect<A, E | Schema.SchemaError, RD>Since v4.0.0
schemaHeaders
Section titled “schemaHeaders”Creates a decoder that validates and decodes an incoming message’s headers with the supplied schema.
Signature
declare const schemaHeaders: <A, I extends Readonly<Record<string, string | undefined>>, RD, RE>( schema: Schema.Codec<A, I, RD, RE>, options?: ParseOptions | undefined) => <E>(self: HttpIncomingMessage<E>) => Effect.Effect<A, Schema.SchemaError, RD>Since v4.0.0
type IDs
Section titled “type IDs”TypeId
Section titled “TypeId”Type identifier for HttpIncomingMessage values.
Signature
declare const TypeId: "~effect/http/HttpIncomingMessage"Since v4.0.0