Skip to content

HttpServerResponse

36 exports Added in v1.0.0 Source

Combinators

expireCookie

Added in v1.0.0 Source

Signature

declare const expireCookie: {
  (
    name: string,
    options?: Omit<
      | {
          readonly domain?: string;
          readonly expires?: Date;
          readonly httpOnly?: boolean;
          readonly maxAge?: Duration.DurationInput;
          readonly partitioned?: boolean;
          readonly path?: string;
          readonly priority?: "low" | "medium" | "high";
          readonly sameSite?: "lax" | "strict" | "none";
          readonly secure?: boolean;
        }
      | undefined,
      "expires" | "maxAge"
    >,
  ): (self: HttpServerResponse) => HttpServerResponse;
  (
    self: HttpServerResponse,
    name: string,
    options?: Omit<
      | {
          readonly domain?: string;
          readonly expires?: Date;
          readonly httpOnly?: boolean;
          readonly maxAge?: Duration.DurationInput;
          readonly partitioned?: boolean;
          readonly path?: string;
          readonly priority?: "low" | "medium" | "high";
          readonly sameSite?: "lax" | "strict" | "none";
          readonly secure?: boolean;
        }
      | undefined,
      "expires" | "maxAge"
    >,
  ): HttpServerResponse;
};

mergeCookies

Added in v1.0.0 Source

Signature

declare const mergeCookies: {
  (cookies: Cookies): (self: HttpServerResponse) => HttpServerResponse;
  (self: HttpServerResponse, cookies: Cookies): HttpServerResponse;
};

removeCookie

Added in v1.0.0 Source

Signature

declare const removeCookie: {
  (name: string): (self: HttpServerResponse) => HttpServerResponse;
  (self: HttpServerResponse, name: string): HttpServerResponse;
};

Signature

declare const replaceCookies: {
  (cookies: Cookies): (self: HttpServerResponse) => HttpServerResponse;
  (self: HttpServerResponse, cookies: Cookies): HttpServerResponse;
};

setBody

Added in v1.0.0 Source

Signature

declare const setBody: {
  (body: HttpBody): (self: HttpServerResponse) => HttpServerResponse;
  (self: HttpServerResponse, body: HttpBody): HttpServerResponse;
};

setCookie

Added in v1.0.0 Source

Signature

declare const setCookie: {
  (
    name: string,
    value: string,
    options?: {
      readonly domain?: string;
      readonly expires?: Date;
      readonly httpOnly?: boolean;
      readonly maxAge?: Duration.DurationInput;
      readonly partitioned?: boolean;
      readonly path?: string;
      readonly priority?: "low" | "medium" | "high";
      readonly sameSite?: "lax" | "strict" | "none";
      readonly secure?: boolean;
    },
  ): (self: HttpServerResponse) => Effect<HttpServerResponse, CookiesError>;
  (
    self: HttpServerResponse,
    name: string,
    value: string,
    options?: {
      readonly domain?: string;
      readonly expires?: Date;
      readonly httpOnly?: boolean;
      readonly maxAge?: Duration.DurationInput;
      readonly partitioned?: boolean;
      readonly path?: string;
      readonly priority?: "low" | "medium" | "high";
      readonly sameSite?: "lax" | "strict" | "none";
      readonly secure?: boolean;
    },
  ): Effect<HttpServerResponse, CookiesError>;
};

setCookies

Added in v1.0.0 Source

Signature

declare const setCookies: {
  (
    cookies: Iterable<
      readonly [
        string,
        string,
        (
          | {
              readonly domain?: string;
              readonly expires?: Date;
              readonly httpOnly?: boolean;
              readonly maxAge?: Duration.DurationInput;
              readonly partitioned?: boolean;
              readonly path?: string;
              readonly priority?: "low" | "medium" | "high";
              readonly sameSite?: "lax" | "strict" | "none";
              readonly secure?: boolean;
            }
          | undefined
        ),
      ]
    >,
  ): (self: HttpServerResponse) => Effect<HttpServerResponse, CookiesError, never>;
  (
    self: HttpServerResponse,
    cookies: Iterable<
      readonly [
        string,
        string,
        (
          | {
              readonly domain?: string;
              readonly expires?: Date;
              readonly httpOnly?: boolean;
              readonly maxAge?: Duration.DurationInput;
              readonly partitioned?: boolean;
              readonly path?: string;
              readonly priority?: "low" | "medium" | "high";
              readonly sameSite?: "lax" | "strict" | "none";
              readonly secure?: boolean;
            }
          | undefined
        ),
      ]
    >,
  ): Effect<HttpServerResponse, CookiesError, never>;
};

setHeader

Added in v1.0.0 Source

Signature

declare const setHeader: {
  (key: string, value: string): (self: HttpServerResponse) => HttpServerResponse;
  (self: HttpServerResponse, key: string, value: string): HttpServerResponse;
};

setHeaders

Added in v1.0.0 Source

Signature

declare const setHeaders: {
  (input: Input): (self: HttpServerResponse) => HttpServerResponse;
  (self: HttpServerResponse, input: Input): HttpServerResponse;
};

setStatus

Added in v1.0.0 Source

Signature

declare const setStatus: {
  (status: number, statusText?: string): (self: HttpServerResponse) => HttpServerResponse;
  (self: HttpServerResponse, status: number, statusText?: string): HttpServerResponse;
};

Signature

declare const unsafeSetCookie: {
  (
    name: string,
    value: string,
    options?: {
      readonly domain?: string;
      readonly expires?: Date;
      readonly httpOnly?: boolean;
      readonly maxAge?: Duration.DurationInput;
      readonly partitioned?: boolean;
      readonly path?: string;
      readonly priority?: "low" | "medium" | "high";
      readonly sameSite?: "lax" | "strict" | "none";
      readonly secure?: boolean;
    },
  ): (self: HttpServerResponse) => HttpServerResponse;
  (
    self: HttpServerResponse,
    name: string,
    value: string,
    options?: {
      readonly domain?: string;
      readonly expires?: Date;
      readonly httpOnly?: boolean;
      readonly maxAge?: Duration.DurationInput;
      readonly partitioned?: boolean;
      readonly path?: string;
      readonly priority?: "low" | "medium" | "high";
      readonly sameSite?: "lax" | "strict" | "none";
      readonly secure?: boolean;
    },
  ): HttpServerResponse;
};

Signature

declare const unsafeSetCookies: {
  (
    cookies: Iterable<
      readonly [
        string,
        string,
        (
          | {
              readonly domain?: string;
              readonly expires?: Date;
              readonly httpOnly?: boolean;
              readonly maxAge?: Duration.DurationInput;
              readonly partitioned?: boolean;
              readonly path?: string;
              readonly priority?: "low" | "medium" | "high";
              readonly sameSite?: "lax" | "strict" | "none";
              readonly secure?: boolean;
            }
          | undefined
        ),
      ]
    >,
  ): (self: HttpServerResponse) => HttpServerResponse;
  (
    self: HttpServerResponse,
    cookies: Iterable<
      readonly [
        string,
        string,
        (
          | {
              readonly domain?: string;
              readonly expires?: Date;
              readonly httpOnly?: boolean;
              readonly maxAge?: Duration.DurationInput;
              readonly partitioned?: boolean;
              readonly path?: string;
              readonly priority?: "low" | "medium" | "high";
              readonly sameSite?: "lax" | "strict" | "none";
              readonly secure?: boolean;
            }
          | undefined
        ),
      ]
    >,
  ): HttpServerResponse;
};

Signature

declare const updateCookies: {
  (f: (cookies: Cookies) => Cookies): (self: HttpServerResponse) => HttpServerResponse;
  (self: HttpServerResponse, f: (cookies: Cookies) => Cookies): HttpServerResponse;
};

Constructors

empty

Added in v1.0.0 Source

Signature

declare const empty: (options?: Options.WithContent) => HttpServerResponse;

file

Added in v1.0.0 Source

Signature

declare const file: (
  path: string,
  options?: Options & FileSystem.StreamOptions,
) => Effect.Effect<HttpServerResponse, PlatformError.PlatformError, Platform.HttpPlatform>;

fileWeb

Added in v1.0.0 Source

Signature

declare const fileWeb: (
  file: Body.HttpBody.FileLike,
  options?: Options.WithContent & FileSystem.StreamOptions,
) => Effect.Effect<HttpServerResponse, never, Platform.HttpPlatform>;

formData

Added in v1.0.0 Source

Signature

declare const formData: (body: FormData, options?: Options.WithContent) => HttpServerResponse;

html

Added in v1.0.0 Source

Signature

declare const html: {
  <A extends readonly Array<Interpolated>>(strings: TemplateStringsArray, ...args: A): Effect<HttpServerResponse, Error<A[number]>, Context<A[number]>>;
  (html: string): HttpServerResponse;
}

htmlStream

Added in v1.0.0 Source

Signature

declare const htmlStream: <A extends ReadonlyArray<Template.InterpolatedWithStream>>(
  strings: TemplateStringsArray,
  ...args: A
) => Effect.Effect<HttpServerResponse, never, Template.Interpolated.Context<A[number]>>;

json

Added in v1.0.0 Source

Signature

declare const json: (
  body: unknown,
  options?: Options.WithContentType,
) => Effect.Effect<HttpServerResponse, Body.HttpBodyError>;

raw

Added in v1.0.0 Source

Signature

declare const raw: (body: unknown, options?: Options) => HttpServerResponse;

redirect

Added in v1.0.0 Source

Signature

declare const redirect: (
  location: string | URL,
  options?: Options.WithContentType,
) => HttpServerResponse;

schemaJson

Added in v1.0.0 Source

Signature

declare const schemaJson: <A, I, R>(
  schema: Schema.Schema<A, I, R>,
  options?: ParseOptions,
) => (
  body: A,
  options?: Options.WithContentType,
) => Effect.Effect<HttpServerResponse, Body.HttpBodyError, R>;

stream

Added in v1.0.0 Source

Signature

declare const stream: <E>(
  body: Stream.Stream<Uint8Array, E, never>,
  options?: Options,
) => HttpServerResponse;

text

Added in v1.0.0 Source

Signature

declare const text: (body: string, options?: Options.WithContentType) => HttpServerResponse;

uint8Array

Added in v1.0.0 Source

Signature

declare const uint8Array: (
  body: Uint8Array,
  options?: Options.WithContentType,
) => HttpServerResponse;

unsafeJson

Added in v1.0.0 Source

Signature

declare const unsafeJson: (body: unknown, options?: Options.WithContentType) => HttpServerResponse;

urlParams

Added in v1.0.0 Source

Signature

declare const urlParams: (
  body: UrlParams.Input,
  options?: Options.WithContentType,
) => HttpServerResponse;

Conversions

fromWeb

Added in v1.0.0 Source

Signature

declare function fromWeb(response: Response): HttpServerResponse;

toWeb

Added in v1.0.0 Source

Signature

declare const toWeb: (
  response: HttpServerResponse,
  options?: {
    readonly runtime?: Runtime.Runtime<never>;
    readonly withoutBody?: boolean;
  },
) => Response;

Models

HttpServerResponse interface

Added in v1.0.0 Source

Signature

interface HttpServerResponse extends Effect<HttpServerResponse>, Inspectable, Respondable {
  readonly [TypeId]: typeof TypeId;
  readonly body: HttpBody;
  readonly cookies: Cookies;
  readonly headers: Headers;
  readonly status: number;
  readonly statusText?: string;
}

Options interface

Added in v1.0.0 Source

Signature

interface Options {
  readonly contentLength?: number;
  readonly contentType?: string;
  readonly cookies?: Cookies;
  readonly headers?: Input;
  readonly status?: number;
  readonly statusText?: string;
}

Other

Signature

declare const isServerResponse: (u: unknown) => u is HttpServerResponse;

Options

Added in v1.0.0 Source

Type Ids

TypeId

Added in v1.0.0 Source

Signature

declare const TypeId: unique symbol;

TypeId type

Added in v1.0.0 Source

Signature

type TypeId = typeof TypeId;