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).
The main difference between this crate and reqwest
is the HTTP client initialization.
First, initialize client using client builder: ```rust 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:
rust
let response = client.get("https://google.ru").send().unwrap();
println!("{response:?}");
To familiarize with request APIs you can see the reqwest docs.
We use tarantool-test. Run tests:
cargo build
tarantool-test -p ./target/debug/libtests.so