4 releases (2 breaking)
0.3.0 | Jan 18, 2024 |
---|---|
0.2.0 | Sep 29, 2023 |
0.1.1 | Sep 26, 2023 |
0.1.0 | Sep 21, 2023 |
#296 in HTTP client
33 downloads per month
21KB
294 lines
Radegast
An HTTP client for picodata apps. Non blocking, fiber friendly, driven by CBUS. Build over reqwest client.
This client has a similar API as reqwest
crate (see docs for more).
Usage example
The main difference between this crate and reqwest
is the HTTP client initialization.
First, initialize client using client builder:
use radegast::ClientBuilder;
use tarantool::cbus;
use tarantool::fiber::Fiber;
pub const CBUS_ENDPOINT: &str = "tests_endpoint";
// initialize cbus first
pub fn init_cbus() {
let mut fiber = Fiber::new("cbus_endpoint_f", &mut |_: Box<()>| {
let cbus_endpoint = cbus::Endpoint::new(CBUS_ENDPOINT).unwrap();
cbus_endpoint.cbus_loop();
0
});
fiber.start(());
}
fn main() {
init_cbus();
let client = radegast::ClientBuilder::new().build(CBUS_ENDPOINT).unwrap();
}
If you want, you can manually define a tokio runtime (instead of default) for run HTTP requests
and reqwest
client underline instance (see ClientBuilder
methods).
Now you have the opportunity to make an HTTP request:
let response = client.get("https://google.ru").send().unwrap();
println!("{response:?}");
To familiarize with request APIs you can see the reqwest docs.
Tests
We use tarantool-test. Run tests:
cargo build
tarantool-test -p ./target/debug/libtests.so
Dependencies
~11–24MB
~373K SLoC