Expand description
The native http module for the Rune Language.
§Usage
Add the following to your Cargo.toml:
rune-modules = { version = "0.14.1", features = ["http", "json"] }Install it into your context:
let mut context = rune::Context::with_default_modules()?;
context.install(rune_modules::http::module(true)?)?;
context.install(rune_modules::json::module(true)?)?;Use it in Rune:
ⓘ
use http;
use json;
fn main() {
let client = http::Client::new();
let response = client.get("http://worldtimeapi.org/api/ip");
let text = response.text();
let json = json::from_string(text);
let timezone = json["timezone"];
if timezone is String {
dbg(timezone);
}
let body = json::to_bytes(#{"hello": "world"});
let response = client.post("https://postman-echo.com/post")
.body_bytes(body)
.send();
let response = json::from_string(response.text());
dbg(response);
}Structs§
- Error
- An error returned by methods in the
httpmodule. - Request
Builder - A builder to construct the properties of a Request.
- Response
- A Response to a submitted [
Request]. - Status
Code - An HTTP status code.
- Version
- HTTP version
Functions§
- module
- A simple HTTP module for Rune.