gluegun
A small HTTP facade for Gluegun.
Construct a timeout and connection options, open and await the connection,
then build and send a request. Always close or terminate the connection,
including after an error. For request customization use gluegun/client;
for streaming use gluegun/request and gluegun/message.
WebSockets have a complete lifecycle API in gluegun/websocket.
Values
pub fn await_up(
connection: connection.Connection,
timeout: connection.Timeout,
) -> Result(connection.Protocol, error.GluegunError)
Wait for connection readiness and the negotiated HTTP protocol.
pub fn body_text(
response: response.Response(BitArray),
) -> Result(String, error.GluegunError)
Decode the response body as UTF-8.
pub fn close(
connection: connection.Connection,
) -> Result(Nil, error.GluegunError)
Stop the connection through Gun’s supervisor; this does not flush messages.
pub fn connection_options() -> connection.ConnectOptions
Construct default connection options, with no automatic retries.
pub fn milliseconds(
value: Int,
) -> Result(connection.Timeout, error.GluegunError)
Construct a timeout from 0 through 4_294_967_295 milliseconds, inclusive.
Returns InvalidOptions outside this range. Use infinity() for no limit.
pub fn new_request(
method: http.Method,
path: String,
) -> client.Request
Construct a request with an empty body and a five-second total budget.
pub fn open(
options: connection.ConnectOptions,
host host: String,
port port: Int,
) -> Result(connection.Connection, error.GluegunError)
Open a connection. Await readiness before sending a request.
pub fn send(
request: client.Request,
connection connection: connection.Connection,
) -> Result(response.Response(BitArray), error.GluegunError)
Send a request and collect its complete HTTP response in memory.
pub fn shutdown(
connection: connection.Connection,
) -> Result(Nil, error.GluegunError)
Request graceful asynchronous shutdown.
pub fn terminate(
connection: connection.Connection,
) -> Result(Nil, error.GluegunError)
Force connection exit and flush its queued messages from this receiver.