HTTP in Eryx

@eryx/http is Eryx's HTTP/1.1 client and server library. It is designed to cover the common "just make a request" workflow, but it also scales down into lower-level transport control when you need connection reuse, streaming, long-polling, or protocol-aware server behavior.

At a high level, the module gives you five layers:

  1. One-shot client helpers like http.get() and http.post().
  2. Pooled client sessions with http.Session.
  3. Low-level persistent transports with http.HttpConnection.
  4. An HTTP server with http.HttpServer.
  5. A higher-level routed app layer with http.App.

The Quickest Start

local http = require("@eryx/http")

local response = http.get("https://httpbin.org/json")
http.raiseForStatus(response)

local data = http.decodeJsonBody(response)
print(data.slideshow.title)

That is the "requests-style" path: make a request, get a buffered response, decode it, move on.

What the Module Handles for You

The client side already covers a lot of HTTP behavior that you normally only notice when it breaks:

The server side also handles a meaningful amount of protocol detail:

Which API Should I Use?

Use http.get(), http.post(), and http.request() when:

Use http.stream() when:

Use http.Session when:

Use http.HttpConnection when:

Use http.HttpServer when:

Use http.App when:

Suggested Reading Order