fetch_event

Types

pub type FetchEvent(body) {
  FetchEvent(request: Request(body))
}

Constructors

  • FetchEvent(request: Request(body))

Functions

pub fn fetch_event_handler(
  handler: fn(FetchEvent(a)) -> Nil,
) -> Nil

Fetch event handler This function is called when a fetch event is triggered eg. when a request is made to the server

pub fn respond_with(
  event: FetchEvent(a),
  handler: fn() -> Response(b),
) -> Nil

Respond with a response This function is used to respond to a fetch event

pub fn respond_with_promise(
  event: FetchEvent(a),
  handler: fn() -> Promise(Response(b)),
) -> Nil

Respond with a promise This function is used to respond to a fetch event with a promise

pub fn to_native_response(response: Response(a)) -> Response(a)

Convert a Gleam Response to a native JavaScript Response

pub fn wait_until(
  event: FetchEvent(a),
  promise: Promise(b),
) -> Nil

Wait until a promise resolves This function to perform asynchronous work without blocking the request/response cycle

Search Document