Skip to content
Welcome to the Gluegun documentation!

gluegun

Minimal common-path facade for the Gluegun HTTP client wrapper.

For full functionality import the submodules (gluegun/connection, gluegun/request, gluegun/client, gluegun/websocket, gluegun/message, gluegun/response, gluegun/error).

Wait until a Gun connection is up.

pub fn await_up(
internal.Connection,
connection.Timeout
) -> Result(connection.Protocol, error.GluegunError)

Decode a response body as UTF-8 text.

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

Construct default connection options.

pub fn connection_options() -> connection.ConnectOptions

Convert a request method to an HTTP method string.

pub fn method_to_string(request.Method) -> String

Return the package name.

pub fn name() -> String

Construct a Request builder.

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

Normalize header names for Gun.

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

Open a Gun connection.

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

Construct a collected HTTP response.

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

Send a Request on an open connection.

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

Construct default TLS options.

pub fn tls_options() -> tls.TlsOptions

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

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

Construct default high-level WebSocket connection options.

pub fn websocket_options() -> websocket.Options

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

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

Send a close WebSocket frame using a reusable socket.

pub fn websocket_send_close_frame(websocket.Socket) -> Result(Nil, error.GluegunError)

Send a text WebSocket frame using a reusable socket.

pub fn websocket_send_text(
websocket.Socket,
String
) -> Result(Nil, 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: websocket.Options,
callback: fn(websocket.Socket) -> Result(a, error.GluegunError)
) -> Result(a, error.GluegunError)

Set connect timeout on connection options.

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

Set protocol preferences on connection options.

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

Set Gun retry timeout on connection options.

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

Set TLS options on connection options.

pub fn with_tls_opts(
connection.ConnectOptions,
tls_opts: tls.TlsOptions
) -> connection.ConnectOptions

Set the transport on connection options.

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