forked from nulang-org/nulang
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhttp.nula
More file actions
20 lines (17 loc) · 834 Bytes
/
Copy pathhttp.nula
File metadata and controls
20 lines (17 loc) · 834 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// Nulang standard library — HTTP client via built-in Http effect.
// Import: `import stdlib::http`
//
// The `Http` effect is wired into both the standalone VM and the runtime host.
// Operations: `perform Http.get(url)` and `perform Http.post(url, body)`.
/// Error type for HTTP operations.
pub type HttpError = Timeout | ConnectionRefused | BadStatus(Int) | Other(String)
/// Perform an HTTP GET request. Returns the response body as a String.
/// Requires the runtime host (not available in standalone VM).
pub fn get(url: String) -> String ! {Http} {
perform Http.get(url)
}
/// Perform an HTTP POST request with a body. Returns the response body as a String.
/// Requires the runtime host (not available in standalone VM).
pub fn post(url: String, body: String) -> String ! {Http} {
perform Http.post(url, body)
}