Best async http library for Moonbit
Dependencies
{
"deps": {
"oboard/mio": "0.5.0"
}
}let response = @mio.get("https://api.github.com") catch {
Err(e) => println("Error: " + e.to_string())
}
println("Response: " + response.text())///|
let client = @mio.RequestClient::builder()
.default_header("User-Agent", "mio")
.timeout(10000)
.build()
///|
let response = client
.post("https://api.example.com/items")
.json({ "name": "moonbit" })
.send()///|
let client = @mio.RequestClient::builder()
.http2_prior_knowledge()
.timeout(10000)
.build()
///|
let response = client.get("http://localhost:3000/").send()
println(response.text())///|
let client = @mio.RequestClient::builder()
.http3_prior_knowledge()
.timeout(10000)
.build()
///|
let response = client.get("https://example.com/").send()
println(response.text())| Mode | Native status | Notes |
|---|---|---|
| HTTP/1.1 | Supported | Direct TCP/TLS transport with streaming APIs. |
| HTTP/2 | Experimental | Prior-knowledge client, HPACK, SETTINGS/HEADERS/DATA, PING, WINDOW_UPDATE, and GOAWAY handling. |
| HTTP/3 | Experimental | UDP QUIC path with X25519, TLS 1.3 ServerHello, EncryptedExtensions, Finished, QUIC Retry, Handshake ACKs, H3 SETTINGS, request streams, and response decoding. |
| JavaScript | Runtime-managed | Uses Fetch; protocol negotiation is handled by the host runtime. |
impl Show for ProxyErrorimpl Show for URIParseErrorasync fn Client::request(self : Client, meth : RequestMethod, path : String, extra_headers? : Map[String, String]) -> Unitpub struct ClientBuilder {
headers : Map[String, String]
proxy : Client?
timeout : Int?
version : HttpVersion
verify : Bool
}fn ClientBuilder::danger_accept_invalid_certs(self : ClientBuilder, enabled : Bool) -> ClientBuilderfn ClientBuilder::default_header(self : ClientBuilder, key : String, value : String) -> ClientBuilderfn ClientBuilder::default_headers(self : ClientBuilder, headers : Map[String, String]) -> ClientBuilderpub struct Cookie {
name : String
value : String
path : String?
expires_raw : String?
max_age : Int64?
domain : String?
secure : Bool
http_only : Bool
extensions : Array[String]
} derive(ToJson, Debug)
fn Cookie::Cookie(name : String, value : String, path? : String, expires_raw? : String, max_age? : Int64, domain? : String, secure? : Bool, http_only? : Bool, extensions? : Array[String]) -> Cookiepub struct RequestBuilder {
client : RequestClient
meth : RequestMethod
uri : String
headers : Map[String, String]
body : &Data
}pub struct RequestClient {
headers : Map[String, String]
proxy : Client?
timeout : Int?
version : HttpVersion
verify : Bool
}fn RequestClient::request(self : RequestClient, meth : RequestMethod, uri : String) -> RequestBuilderasync fn delete(uri : String, headers? : Map[String, String], body? : &Data, proxy? : Client) -> ResponseBodyasync fn get(uri : String, headers? : Map[String, String], body? : &Data, proxy? : Client) -> ResponseBodyasync fn options(uri : String, headers? : Map[String, String], body? : &Data, proxy? : Client) -> ResponseBodyasync fn patch(uri : String, content : &Data, headers? : Map[String, String], proxy? : Client) -> ResponseBodyasync fn post(uri : String, content : &Data, headers? : Map[String, String], proxy? : Client) -> ResponseBodyasync fn put(uri : String, content : &Data, headers? : Map[String, String], proxy? : Client) -> ResponseBodyBest async http library for Moonbit
Dependencies