Gleam bindings to the Erlang gun HTTP/1.1, HTTP/2 and Websocket client.

Currently this library is rather basic and only supports a portion of the websocket API. Let us know if you need more.


This package can be added to your Gleam project like so.

gleam add nerf

Then use it in your Gleam application.

import nerf/websocket

pub fn main() {
  // Connect
  assert Ok(conn) = websocket.connect("", "/ws", 8080, [])

  // Send some messages
  websocket.send(conn, "Hello")
  websocket.send(conn, "World")

  // Receive some messages
  assert Ok(Text("Hello")) = websocket.receive(conn, 500)
  assert Ok(Text("World")) = websocket.receive(conn, 500)

  // Close the connection

Testing this library

podman run --rm --detach -p 8080:8080 --name echo jmalloc/echo-server
gleam test