finch

Finch API wrapper module.

See the Finch documentation for additional information about the functions.

Types

Exception returned by Finch in case of request errors.

pub external type Exception

Finch request, use build/2 to create one from a Gleam request.

pub external type Request
pub type RequestOption {
  PoolTimeout(ms: Int)
  RequestTimeout(ms: Int)
}

Constructors

  • PoolTimeout(ms: Int)
  • RequestTimeout(ms: Int)
pub type RequestOptions =
  List(RequestOption)

Functions

pub fn build(req: Request(String), opts: List(RequestOption)) -> finch.Request

Build a Finch request that can be run with request/2 or stream/5.

Note, the HTTP methods CONNECT, TRACE, and Other(String) are not supported, and will be converted to GET.

pub fn request(req: Request, name: Atom) -> Result(
  Response(String),
  Exception,
)

Send a request using the Finch instance with the given name.

pub external fn start_link(opts: InstanceOptions) -> OnStart

Start a new Finch instance with the given options.

pub external fn stream(
  req: Request,
  name: Atom,
  acc: a,
  fun: StreamFun(a),
  opts: RequestOptions,
) -> Result(a, Exception)

Stream a request using the Finch instance with the given name.

Search Document