-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to depend on ic-utils
for http_request
interface when targeting Wasm
#201
Comments
In case anyone else is looking to do this, or looking to make a PR, here's some info. I created a local crate called
I worked around it by doing the following: diff --git a/src/ic-utils-http-request/src/lib.rs b/src/ic-utils-http-request/src/lib.rs
index 1b5b6ed..a649e25 100644
--- a/src/ic-utils-http-request/src/lib.rs
+++ b/src/ic-utils-http-request/src/lib.rs
@@ -14,12 +14,12 @@ use ic_cdk::export::candid::{CandidType, Deserialize};
pub struct HeaderField(pub String, pub String);
#[derive(CandidType, Deserialize)]
-pub struct HttpRequest<'body> {
+pub struct HttpRequest {
pub method: String,
pub url: String,
pub headers: Vec<HeaderField>,
#[serde(with = "serde_bytes")]
- pub body: &'body [u8],
+ pub body: Vec<u8>,
}
#[derive(CandidType, Deserialize)] I suspect I can avoid that by adding a type annotation at the call site (below) but haven't been able to figure that out yet. #[query]
fn http_request(request: HttpRequest) -> HttpResponse {
HttpResponse {
status_code: 200,
headers: vec![],
body: request.body.to_vec(),
streaming_strategy: None,
}
} @chenyan-dfinity, do you have any suggestions? |
Could be a CDK issue. Not sure if CDK allows deserializing borrowed arguments. One thing you can try is to use |
I added
ic-utils = "0.3.1"
to the[dependencies]
section of myCargo.toml
file so I could do the following:However, that caused
cargo build --target wasm32-unknown-unknown --package <my package> --release
to fail.ic-utils
appears to transitively depend onopenssl-sys
, and apparently theopenssl
crate doesn't have support for WebAssembly.I'll probably copy and paste what I need from
http_request.rs
for now but it would be great if we could depend on a crate from this repo that includes them instead.The text was updated successfully, but these errors were encountered: