mirror of
https://github.com/bearlanguageorg/bear.git
synced 2026-08-26 15:37:18 +00:00
More buildins and vscode exstention <CO-AUthored, ai>
This commit is contained in:
+23
@@ -21,3 +21,26 @@ fn post(url, data) {
|
||||
fn get_text(url) {
|
||||
return http_get(url).body
|
||||
}
|
||||
|
||||
// request sends any method with custom headers (a {name: value} struct) and
|
||||
// a timeout in milliseconds, and returns {status, body}. A timeout <= 0 uses
|
||||
// the default (30s). Network failures throw; HTTP errors are normal responses.
|
||||
fn request(method, url, data, headers, timeout_ms) {
|
||||
return http_req(method, url, data, headers, timeout_ms)
|
||||
}
|
||||
|
||||
fn get_with_headers(url, headers) {
|
||||
return http_req("GET", url, "", headers, 0)
|
||||
}
|
||||
|
||||
fn post_with_headers(url, data, headers) {
|
||||
return http_req("POST", url, data, headers, 0)
|
||||
}
|
||||
|
||||
fn get_timeout(url, timeout_ms) {
|
||||
return http_req("GET", url, "", {}, timeout_ms)
|
||||
}
|
||||
|
||||
fn post_timeout(url, data, timeout_ms) {
|
||||
return http_req("POST", url, data, {}, timeout_ms)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user