mirror of
https://github.com/bearlanguageorg/bear.git
synced 2026-08-26 15:37:18 +00:00
Time lib and http
This commit is contained in:
+23
@@ -0,0 +1,23 @@
|
||||
// http.vr — HTTP client (part of the VuurRaaf stdlib).
|
||||
//
|
||||
// import http
|
||||
// let res = http.get("https://api.example.com/status")
|
||||
// println(str(res.status))
|
||||
// println(res.body)
|
||||
//
|
||||
// http.get / http.post return a struct with `status` (int) and `body`
|
||||
// (string). Network failures (DNS, refused, timeout) throw, so they can be
|
||||
// caught with try/catch; HTTP-level errors (404, 500) are normal responses.
|
||||
|
||||
fn get(url) {
|
||||
return http_get(url)
|
||||
}
|
||||
|
||||
fn post(url, data) {
|
||||
return http_post(url, data)
|
||||
}
|
||||
|
||||
// get_text returns just the response body as a string.
|
||||
fn get_text(url) {
|
||||
return http_get(url).body
|
||||
}
|
||||
Reference in New Issue
Block a user