Module http/index
http/index
HTTP client library — types, request building, and async fetching.
Types
HttpMethod
enum
HttpMethod
Variants
| Variant | Fields | Description |
|---|---|---|
GET | ||
POST | ||
PUT | ||
DELETE | ||
HEAD | ||
PATCH |
HttpHeader
object
HttpRequest
object
HttpRequest
Fields
| Name | Type | Description |
|---|---|---|
method | HttpMethod | |
path | String | |
headers | ArrayList(HttpHeader) | |
body | String |
Methods
new : (HttpRequest) fn(method : HttpMethod, path : String) -> HttpRequestheader : (HttpRequest) fn(self : HttpRequest, name : String, value : String) -> HttpRequestwith_body : (HttpRequest) fn(self : HttpRequest, body : String) -> HttpRequestset_host : (HttpRequest) fn(self : HttpRequest, host : String) -> unitset_header : (HttpRequest) fn(self : HttpRequest, name : String, value : String) -> unitset_body : (HttpRequest) fn(self : HttpRequest, body : String) -> unitto_string : (HttpRequest) fn(self : HttpRequest) -> String
HttpResponse
object
HttpResponse
Fields
| Name | Type | Description |
|---|---|---|
status_code | i32 | |
status_text | String | |
headers | ArrayList(HttpHeader) | |
body | String |
Methods
new : (HttpResponse) fn(status_code : i32, status_text : String) -> HttpResponseget_header : (HttpResponse) fn(self : HttpResponse, name : String) -> Option(String)is_ok : (HttpResponse) fn(self : HttpResponse) -> boolis_redirect : (HttpResponse) fn(self : HttpResponse) -> boolis_error : (HttpResponse) fn(self : HttpResponse) -> bool
HttpError
enum
FetchOptions
object
FetchOptions
Fields
| Name | Type | Description |
|---|---|---|
method | HttpMethod | |
headers | ArrayList(HttpHeader) | |
body | String |
Methods
new : (FetchOptions) fn() -> FetchOptionsReturns: FetchOptions
with_method : (FetchOptions) fn(self : FetchOptions, method : HttpMethod) -> FetchOptionswith_header : (FetchOptions) fn(self : FetchOptions, name : String, value : String) -> FetchOptionswith_body : (FetchOptions) fn(self : FetchOptions, body : String) -> FetchOptionsFunctions
parse_response
function
fn(raw : String) -> Result(HttpResponse, String)
Parameters
| Name | Type | Notes |
|---|---|---|
raw | String |
Returns: Result(HttpResponse, String)
http_status_text
function
fetch_with
function
fn(url_str : String, opts : FetchOptions, using(io : IO)) -> Impl(Future(HttpResponse, IO, Exception))
Parameters
| Name | Type | Notes |
|---|---|---|
url_str | String | |
opts | FetchOptions |
Effects
| Name | Type | Notes |
|---|---|---|
io | IO | comptime, implicit |
Returns: Impl(Future(HttpResponse, IO, Exception))