Files
plainleaf/website/API/net.md
T
Zef Hemel 7cec9b6121 Lua: introduce net.* APIs and deprecate http.request in favor of new
net.proxyFetch API

Introduces foundation support for URIs (net.readURI, net.writeURI).
2025-11-07 10:51:17 +01:00

788 B

Network-related APIs.

net.proxyRequest(url, options?)

Performs a HTTP call, proxied via the server (to avoid CORS issues, see HTTP API).

Options:

  • method: GET, POST, PUT, DELETE (GET is default)
  • headers: table with header -> value mappings
  • body: either a string or table (which will be JSON stringified)

Returns:

  • ok: boolean if the request went ok
  • status: HTTP status code
  • headers: HTTP headers
  • body: for content types:
    • text/*: string
    • application/json: parsed JSON object
    • anything else: UInt8Array

net.readURI(uri, options?)

Fetches the content of a URIs.

Options:

  • encoding force an encoding for the result, e.g. {encoding = "text/markdown"}

net.writeURI(uri, content)

Writes content to a specific URIs.