Request¶
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()andhead()returnRequestOptions— no body methods available.post(),put(),patch(),delete(), andoptions()returnRequestOptionsWithBody— 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()
Constructors¶
create¶
Returns¶
- Request val^
Public Functions¶
get¶
Create a GET request builder.
Parameters¶
- path: String val
Returns¶
- RequestOptions ref^
head¶
Create a HEAD request builder.
Parameters¶
- path: String val
Returns¶
- RequestOptions ref^
delete¶
Create a DELETE request builder.
Parameters¶
- path: String val
Returns¶
options¶
Create an OPTIONS request builder.
Parameters¶
- path: String val
Returns¶
post¶
Create a POST request builder.
Parameters¶
- path: String val
Returns¶
put¶
Create a PUT request builder.
Parameters¶
- path: String val
Returns¶
patch¶
Create a PATCH request builder.
Parameters¶
- path: String val
Returns¶
eq¶
Parameters¶
- that: Request val
Returns¶
- Bool val
ne¶
Parameters¶
- that: Request val
Returns¶
- Bool val