Skip to content
Gluegun logoGluegun logo

Gluegun

HTTP/1.1, HTTP/2, and WebSocket clients for Gleam on the BEAM.

HTTP without footguns.

Gluegun keeps the BEAM-native Gun model visible. Open a connection. Wait for the negotiated protocol. Send the request. Then collect a typed response, or use streams when the body does not fit in memory.

use conn <- result.try(
connection.options()
|> connection.open(host: "example.com", port: 443),
)
use _ <- result.try(
connection.await_up(conn, connection.Milliseconds(5000)),
)
use res <- result.try(
client.new(request.Get, "/")
|> client.with_timeout(timeout: connection.Milliseconds(5000))
|> client.send(connection: conn),
)
io.println("status: " <> int.to_string(response.status(res)))
connection.close(conn)

client.send collects status, headers, body, trailers, and informational 1xx responses into one typed value. Use the lower-level request and message APIs when you must stream the response.

Select the layer that agrees with the task.

Use the high-level client when one collected response is sufficient. Use the request and message functions when streams, cancellation, HTTP/2 push, upgrades, trailers, or WebSocket frames must stay explicit.