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 type Exception

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

pub 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 fn start_link(opts opts: List(InstanceOption)) -> OnStart

Start a new Finch instance with the given options.

pub fn stream(req req: Request, name name: Atom, acc acc: a, fun fun: fn(
    StreamBlock,
    a,
  ) -> a, opts opts: List(RequestOption)) -> Result(a, Exception)

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

Search Document