canhttp
Library to make HTTPs outcalls from a canister on the Internet Computer, leveraging the modularity of the tower framework.
Usage
Add this to your Cargo.toml (see crates.io for the latest version):
= "0.2.1"
Then, use the library to create an HTTP POST request, as follows:
let request = post
.max_response_bytes
.header
.body
.unwrap;
let response = http_client
.ready
.await
.expect
.call
.await
.expect;
Complete examples are available here and see also the Rust documentation for more details.
Cargo Features
Feature http
Offers middleware that transforms a low-level service that uses Candid types into one that uses types from the http crate. See the http_canister for a complete example.
Feature json
Offers middleware that transforms a low-level service that transmits bytes into one that transmits JSON payloads. See the json_rpc_canister for a complete example.
Feature multi
Make multiple calls in parallel and handle their multiple results. See the multi_canister for a complete example.
License
This project is licensed under the Apache License 2.0.