gossamer
Web API bindings for Gleam, targeting JavaScript runtimes (Deno, Node.js, Bun, and browsers).
Installation
gleam add gossamer
Usage
import gossamer
import gossamer/promise
import gossamer/response
import gossamer/url
pub fn main() {
let parsed = url.new("https://example.com/path?q=gleam")
let hostname = url.hostname(parsed) // "example.com"
use resp <- promise.then(gossamer.fetch("https://example.com"))
use body <- promise.then(response.text(resp))
promise.resolve(body)
}
Modules
Core Types
- promise —
Promisewiththen,catch,all,race,any,all_settled,with_resolvers - uint8_array — Complete
Uint8ArrayAPI including base64/hex encoding - array_buffer —
ArrayBufferbindings - blob —
Blobcreation and reading - file —
Filetype (extends Blob) - json — JSON parse/stringify with Gleam types
Networking & HTTP
- headers —
Headerswith get/set/append/delete/keys/values/entries - request —
Requestconstruction and properties - response —
Responseconstruction, reading, and cloning - url —
URLparsing and manipulation - url_search_params — Query string handling
- web_socket —
WebSocketclient with typed events - form_data —
FormDatafor multipart form handling
Streams
- readable_stream —
ReadableStreamwith reader/controller/piping - writable_stream —
WritableStreamwith writer/controller - transform_stream —
TransformStreamwith transformer - compression_stream / decompression_stream — gzip/deflate/brotli
Crypto
- crypto —
getRandomValues,randomUUID - subtle_crypto — digest, encrypt/decrypt, sign/verify, key generation/import/export, derive, wrap/unwrap
- crypto_key / crypto_key_pair — Key types and properties
Text Encoding
- text_encoder / text_decoder — UTF-8 encoding/decoding
- text_encoder_stream / text_decoder_stream — Streaming variants
Other
- abort_controller / abort_signal — Cancellation
- iterator / async_iterator — JS iterator protocol
Top-level (gossamer)
fetch,fetch_with_init,fetch_requestset_timeout,clear_timeout,set_interval,clear_intervalqueue_microtask,report_erroralert,confirm,prompt,close