Skip to content
Welcome to the Gluegun documentation!

gluegun

Root facade for the Gluegun HTTP client wrapper.

This module exposes a small common-path facade. Submodules expose grouped APIs for connection, low-level request, response, message, and WebSocket concerns.

Decode a response body as UTF-8 text.

pub fn body_text(gluegun/response.Response) -> Result(String, gluegun/error.GluegunError)

Construct default connection options.

pub fn connection_options() -> gluegun/connection.ConnectOptions

Convert a request method to an HTTP method string.

pub fn method_to_string(gluegun/request.Method) -> String

Return the package name.

pub fn name() -> String

Normalize header names for Gun.

pub fn normalize_headers(List(#(String, String))) -> List(#(String, String))

Open a Gun connection.

pub fn open(gluegun/connection.ConnectOptions, host: String, port: Int) -> Result(gluegun/internal.Connection, gluegun/error.GluegunError)

Send one request and collect the full response.

pub fn request(gluegun/request.Method, String) -> gluegun/client.Request

Construct a collected HTTP response.

pub fn response(status: Int, headers: List(#(String, String)), body: BitArray, trailers: List(#(String, String))) -> gluegun/response.Response

Send a collected HTTP request command.

pub fn send(gluegun/client.Request, connection: gluegun/internal.Connection) -> Result(gluegun/response.Response, gluegun/error.GluegunError)

Send a close WebSocket frame using a reusable socket.

pub fn websocket_close(gluegun/websocket.Socket) -> Result(Nil, gluegun/error.GluegunError)

Open a connection, perform a WebSocket upgrade, and return a reusable socket.

pub fn websocket_connect(host: String, port: Int, path: String, options: gluegun/websocket.Options) -> Result(gluegun/websocket.Socket, gluegun/error.GluegunError)

Construct default high-level WebSocket connection options.

pub fn websocket_options() -> gluegun/websocket.Options

Receive the next application WebSocket frame, handling ping/pong frames.

pub fn websocket_receive_app_frame(gluegun/websocket.Socket) -> Result(gluegun/message.Frame, gluegun/error.GluegunError)

Send a text WebSocket frame using a reusable socket.

pub fn websocket_send_text(gluegun/websocket.Socket, String) -> Result(Nil, gluegun/error.GluegunError)

Open a WebSocket, run a callback, then close the WebSocket and connection.

pub fn websocket_with_socket(host: String, port: Int, path: String, options: gluegun/websocket.Options, callback: fn(gluegun/websocket.Socket) -> Result(a, gluegun/error.GluegunError)) -> Result(a, gluegun/error.GluegunError)

Set connect timeout on connection options.

pub fn with_connect_timeout(gluegun/connection.ConnectOptions, timeout: gluegun/connection.Timeout) -> gluegun/connection.ConnectOptions

Set protocol preferences on connection options.

pub fn with_protocols(gluegun/connection.ConnectOptions, protocols: List(gluegun/connection.Protocol)) -> gluegun/connection.ConnectOptions

Set Gun retry timeout on connection options.

pub fn with_retry(gluegun/connection.ConnectOptions, retry: gluegun/connection.Timeout) -> gluegun/connection.ConnectOptions

Set the transport on connection options.

pub fn with_transport(gluegun/connection.ConnectOptions, transport: gluegun/connection.Transport) -> gluegun/connection.ConnectOptions