Skip to main content Link Search Menu Expand Document (external link)

HttpServer overview

Added in v1.0.0


Table of contents


accessors

serve

Signature

export declare const serve: {
  (): <E, R>(
    httpApp: App.Default<E, R>
  ) => Layer.Layer<never, never, HttpServer | Exclude<R, ServerRequest.HttpServerRequest | Scope.Scope>>
  <E, R, App extends App.Default<any, any>>(
    middleware: Middleware.HttpMiddleware.Applied<App, E, R>
  ): (
    httpApp: App.Default<E, R>
  ) => Layer.Layer<
    never,
    never,
    HttpServer | Exclude<Effect.Effect.Context<App>, ServerRequest.HttpServerRequest | Scope.Scope>
  >
  <E, R>(
    httpApp: App.Default<E, R>
  ): Layer.Layer<never, never, HttpServer | Exclude<R, ServerRequest.HttpServerRequest | Scope.Scope>>
  <E, R, App extends App.Default<any, any>>(
    httpApp: App.Default<E, R>,
    middleware: Middleware.HttpMiddleware.Applied<App, E, R>
  ): Layer.Layer<
    never,
    never,
    HttpServer | Exclude<Effect.Effect.Context<App>, ServerRequest.HttpServerRequest | Scope.Scope>
  >
}

Added in v1.0.0

serveEffect

Signature

export declare const serveEffect: {
  (): <E, R>(
    httpApp: App.Default<E, R>
  ) => Effect.Effect<void, never, Scope.Scope | HttpServer | Exclude<R, ServerRequest.HttpServerRequest>>
  <E, R, App extends App.Default<any, any>>(
    middleware: Middleware.HttpMiddleware.Applied<App, E, R>
  ): (
    httpApp: App.Default<E, R>
  ) => Effect.Effect<
    void,
    never,
    Scope.Scope | HttpServer | Exclude<Effect.Effect.Context<App>, ServerRequest.HttpServerRequest>
  >
  <E, R>(
    httpApp: App.Default<E, R>
  ): Effect.Effect<void, never, Scope.Scope | HttpServer | Exclude<R, ServerRequest.HttpServerRequest>>
  <E, R, App extends App.Default<any, any>>(
    httpApp: App.Default<E, R>,
    middleware: Middleware.HttpMiddleware.Applied<App, E, R>
  ): Effect.Effect<
    void,
    never,
    Scope.Scope | HttpServer | Exclude<Effect.Effect.Context<App>, ServerRequest.HttpServerRequest>
  >
}

Added in v1.0.0

address

Address (type alias)

Signature

export type Address = UnixAddress | TcpAddress

Added in v1.0.0

TcpAddress (interface)

Signature

export interface TcpAddress {
  readonly _tag: "TcpAddress"
  readonly hostname: string
  readonly port: number
}

Added in v1.0.0

UnixAddress (interface)

Signature

export interface UnixAddress {
  readonly _tag: "UnixAddress"
  readonly path: string
}

Added in v1.0.0

addressFormattedWith

Signature

export declare const addressFormattedWith: <A, E, R>(
  effect: (address: string) => Effect.Effect<A, E, R>
) => Effect.Effect<A, E, HttpServer | R>

Added in v1.0.0

addressWith

Signature

export declare const addressWith: <A, E, R>(
  effect: (address: Address) => Effect.Effect<A, E, R>
) => Effect.Effect<A, E, HttpServer | R>

Added in v1.0.0

formatAddress

Signature

export declare const formatAddress: (address: Address) => string

Added in v1.0.0

logAddress

Signature

export declare const logAddress: Effect.Effect<void, never, HttpServer>

Added in v1.0.0

withLogAddress

Signature

export declare const withLogAddress: <A, E, R>(
  layer: Layer.Layer<A, E, R>
) => Layer.Layer<A, E, R | Exclude<HttpServer, A>>

Added in v1.0.0

constructors

HttpServer

Signature

export declare const HttpServer: Context.Tag<HttpServer, HttpServer>

Added in v1.0.0

make

Signature

export declare const make: (options: {
  readonly serve: (
    httpApp: App.Default<unknown>,
    middleware?: Middleware.HttpMiddleware
  ) => Effect.Effect<void, never, Scope.Scope>
  readonly address: Address
}) => HttpServer

Added in v1.0.0

layers

layerContext

A Layer providing the HttpPlatform, FileSystem, Etag.Generator, and Path services.

The FileSystem service is a no-op implementation, so this layer is only useful for platforms that have no file system.

Signature

export declare const layerContext: Layer.Layer<FileSystem | Path | HttpPlatform | Generator>

Added in v1.0.0

layerTestClient

Layer producing an HttpClient with prepended url of the running http server.

Signature

export declare const layerTestClient: Layer.Layer<
  Client.HttpClient<HttpClientError, Scope.Scope>,
  never,
  HttpServer | Client.HttpClient<HttpClientError, Scope.Scope>
>

Added in v1.0.0

models

HttpServer (interface)

Signature

export interface HttpServer {
  readonly [TypeId]: TypeId
  readonly serve: {
    <E, R>(
      httpApp: App.Default<E, R>
    ): Effect.Effect<void, never, Exclude<R, ServerRequest.HttpServerRequest> | Scope.Scope>
    <E, R, App extends App.Default<any, any>>(
      httpApp: App.Default<E, R>,
      middleware: Middleware.HttpMiddleware.Applied<App, E, R>
    ): Effect.Effect<void, never, Exclude<R, ServerRequest.HttpServerRequest> | Scope.Scope>
  }
  readonly address: Address
}

Added in v1.0.0

ServeOptions (interface)

Signature

export interface ServeOptions {
  readonly respond: boolean
}

Added in v1.0.0

type ids

TypeId

Signature

export declare const TypeId: typeof TypeId

Added in v1.0.0

TypeId (type alias)

Signature

export type TypeId = typeof TypeId

Added in v1.0.0