Skip to content

Request

[Source]

Factory for building HTTP requests with a typed step-builder pattern.

Each factory method returns a builder typed according to whether the HTTP method supports a body:

  • get() and head() return RequestOptions — no body methods available.
  • post(), put(), patch(), delete(), and options() return RequestOptionsWithBody — body methods are available, but optional.

After calling a body method, the return type narrows to RequestOptions, preventing the body from being set twice.

CONNECT and TRACE are intentionally omitted. CONNECT is for proxy tunneling (not standard request/response) and TRACE is a diagnostic verb rarely used by application code. Both exist as Method primitives and can be used directly: HTTPRequest(CONNECT, path) / HTTPRequest(TRACE, path).

// Simple GET
let req = Request.get("/users").build()

// GET with query params and auth
let req = Request.get("/search")
  .query("q", "pony lang")
  .bearer_auth("my-token")
  .build()

// POST with JSON body
let req = Request.post("/users")
  .json_body("{\"name\": \"Alice\"}")
  .build()

// POST with form body
let req = Request.post("/login")
  .form_body(recover val [("user", "alice"); ("pass", "secret")] end)
  .build()

// POST with multipart form data
let form = MultipartFormData
  .> field("username", "alice")
  .> file("avatar", "photo.jpg", "image/jpeg", image_data)
let req = Request.post("/upload")
  .multipart_body(form)
  .build()
primitive val Request

Constructors

create

[Source]

new val create()
: Request val^

Returns


Public Functions

get

[Source]

Create a GET request builder.

fun box get(
  path: String val)
: RequestOptions ref^

Parameters

Returns


[Source]

Create a HEAD request builder.

fun box head(
  path: String val)
: RequestOptions ref^

Parameters

Returns


delete

[Source]

Create a DELETE request builder.

fun box delete(
  path: String val)
: RequestOptionsWithBody ref^

Parameters

Returns


options

[Source]

Create an OPTIONS request builder.

fun box options(
  path: String val)
: RequestOptionsWithBody ref^

Parameters

Returns


post

[Source]

Create a POST request builder.

fun box post(
  path: String val)
: RequestOptionsWithBody ref^

Parameters

Returns


put

[Source]

Create a PUT request builder.

fun box put(
  path: String val)
: RequestOptionsWithBody ref^

Parameters

Returns


patch

[Source]

Create a PATCH request builder.

fun box patch(
  path: String val)
: RequestOptionsWithBody ref^

Parameters

Returns


eq

[Source]

fun box eq(
  that: Request val)
: Bool val

Parameters

Returns


ne

[Source]

fun box ne(
  that: Request val)
: Bool val

Parameters

Returns