| Crates.io | canhttp |
| lib.rs | canhttp |
| version | 0.4.0 |
| created_at | 2025-06-04 14:23:15.969481+00 |
| updated_at | 2025-11-21 16:57:40.890209+00 |
| description | Rust library to issue HTTPs outcalls from a canister on the Internet Computer |
| homepage | https://github.com/dfinity/canhttp |
| repository | https://github.com/dfinity/canhttp |
| max_upload_size | |
| id | 1700476 |
| size | 235,779 |
Library to make HTTPs outcalls from a canister on the Internet Computer, leveraging the modularity of the tower framework.
Add this to your Cargo.toml (see crates.io for the latest version):
canhttp = "0.2.1"
Then, use the library to create an HTTP POST request, as follows:
let request = http::Request::post("https://httpbin.org/anything")
.max_response_bytes(1_000)
.header("X-Id", "42")
.body("Hello, World!".as_bytes().to_vec())
.unwrap();
let response = http_client()
.ready()
.await
.expect("Client should be ready")
.call(request)
.await
.expect("Request should succeed");
Complete examples are available here and see also the Rust documentation for more details.
httpOffers 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.
jsonOffers 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.
multiMake multiple calls in parallel and handle their multiple results. See the multi_canister for a complete example.
This project is licensed under the Apache License 2.0.