Struct ic_utils::interfaces::http_request::HttpRequestCanister
source · [−]pub struct HttpRequestCanister<'agent>(_);Expand description
A canister that can serve a HTTP request.
Implementations
sourceimpl<'agent> HttpRequestCanister<'agent>
impl<'agent> HttpRequestCanister<'agent>
sourcepub fn create(agent: &'agent Agent, canister_id: Principal) -> Self
pub fn create(agent: &'agent Agent, canister_id: Principal) -> Self
Create an instance of a HttpRequestCanister interface pointing to the specified Canister ID.
sourcepub fn from_canister(canister: Canister<'agent>) -> Self
pub fn from_canister(canister: Canister<'agent>) -> Self
Create a HttpRequestCanister interface from an existing canister object.
sourceimpl<'agent> HttpRequestCanister<'agent>
impl<'agent> HttpRequestCanister<'agent>
sourcepub fn http_request<'canister: 'agent>(
&'canister self,
method: impl AsRef<str>,
url: impl AsRef<str>,
headers: impl IntoIterator<Item = HeaderField<'agent>, IntoIter = impl 'agent + Send + Sync + Clone + ExactSizeIterator<Item = HeaderField<'agent>>>,
body: impl AsRef<[u8]>
) -> impl 'agent + SyncCall<(HttpResponse,)>
pub fn http_request<'canister: 'agent>(
&'canister self,
method: impl AsRef<str>,
url: impl AsRef<str>,
headers: impl IntoIterator<Item = HeaderField<'agent>, IntoIter = impl 'agent + Send + Sync + Clone + ExactSizeIterator<Item = HeaderField<'agent>>>,
body: impl AsRef<[u8]>
) -> impl 'agent + SyncCall<(HttpResponse,)>
Performs a HTTP request, receiving a HTTP response.
sourcepub fn http_request_custom<'canister: 'agent, H, T, C>(
&'canister self,
method: &str,
url: &str,
headers: H,
body: &[u8]
) -> impl 'agent + SyncCall<(HttpResponse<T, C>,)>where
H: 'agent + Send + Sync + Clone + ExactSizeIterator<Item = HeaderField<'agent>>,
T: 'agent + Send + Sync + CandidType + for<'de> Deserialize<'de>,
C: 'agent + Send + Sync + CandidType + for<'de> Deserialize<'de>,
pub fn http_request_custom<'canister: 'agent, H, T, C>(
&'canister self,
method: &str,
url: &str,
headers: H,
body: &[u8]
) -> impl 'agent + SyncCall<(HttpResponse<T, C>,)>where
H: 'agent + Send + Sync + Clone + ExactSizeIterator<Item = HeaderField<'agent>>,
T: 'agent + Send + Sync + CandidType + for<'de> Deserialize<'de>,
C: 'agent + Send + Sync + CandidType + for<'de> Deserialize<'de>,
Performs a HTTP request, receiving a HTTP response.
T and C are the token and callback types for the streaming_strategy.
sourcepub fn http_request_update<'canister: 'agent>(
&'canister self,
method: impl AsRef<str>,
url: impl AsRef<str>,
headers: impl 'agent + Send + Sync + Clone + ExactSizeIterator<Item = HeaderField<'agent>>,
body: impl AsRef<[u8]>
) -> impl 'agent + AsyncCall<(HttpResponse,)>
pub fn http_request_update<'canister: 'agent>(
&'canister self,
method: impl AsRef<str>,
url: impl AsRef<str>,
headers: impl 'agent + Send + Sync + Clone + ExactSizeIterator<Item = HeaderField<'agent>>,
body: impl AsRef<[u8]>
) -> impl 'agent + AsyncCall<(HttpResponse,)>
Performs a HTTP request over an update call. Unlike query calls, update calls must pass consensus and therefore cannot be tampered with by a malicious node.
sourcepub fn http_request_update_custom<'canister: 'agent, H, T, C>(
&'canister self,
method: &str,
url: &str,
headers: H,
body: &[u8]
) -> impl 'agent + AsyncCall<(HttpResponse<T, C>,)>where
H: 'agent + Send + Sync + Clone + ExactSizeIterator<Item = HeaderField<'agent>>,
T: 'agent + Send + Sync + CandidType + for<'de> Deserialize<'de>,
C: 'agent + Send + Sync + CandidType + for<'de> Deserialize<'de>,
pub fn http_request_update_custom<'canister: 'agent, H, T, C>(
&'canister self,
method: &str,
url: &str,
headers: H,
body: &[u8]
) -> impl 'agent + AsyncCall<(HttpResponse<T, C>,)>where
H: 'agent + Send + Sync + Clone + ExactSizeIterator<Item = HeaderField<'agent>>,
T: 'agent + Send + Sync + CandidType + for<'de> Deserialize<'de>,
C: 'agent + Send + Sync + CandidType + for<'de> Deserialize<'de>,
Performs a HTTP request over an update call. Unlike query calls, update calls must pass consensus
and therefore cannot be tampered with by a malicious node.
T and C are the token and callback types for the streaming_strategy.
sourcepub fn http_request_stream_callback<'canister: 'agent>(
&'canister self,
method: impl AsRef<str>,
token: Token
) -> impl 'agent + SyncCall<(StreamingCallbackHttpResponse,)>
pub fn http_request_stream_callback<'canister: 'agent>(
&'canister self,
method: impl AsRef<str>,
token: Token
) -> impl 'agent + SyncCall<(StreamingCallbackHttpResponse,)>
Retrieves the next chunk of a stream from a streaming callback, using the method from CallbackStrategy.
sourcepub fn http_request_stream_callback_custom<'canister: 'agent, T>(
&'canister self,
method: impl AsRef<str>,
token: T
) -> impl 'agent + SyncCall<(StreamingCallbackHttpResponse<T>,)>where
T: 'agent + Send + Sync + CandidType + for<'de> Deserialize<'de>,
pub fn http_request_stream_callback_custom<'canister: 'agent, T>(
&'canister self,
method: impl AsRef<str>,
token: T
) -> impl 'agent + SyncCall<(StreamingCallbackHttpResponse<T>,)>where
T: 'agent + Send + Sync + CandidType + for<'de> Deserialize<'de>,
Retrieves the next chunk of a stream from a streaming callback, using the method from CallbackStrategy.
T is the token type.
Methods from Deref<Target = Canister<'agent>>
sourcepub fn canister_id_<'canister: 'agent>(&'canister self) -> &'_ Principal
pub fn canister_id_<'canister: 'agent>(&'canister self) -> &'_ Principal
Get the canister ID of this canister.
sourcepub fn update_<'canister: 'agent>(
&'canister self,
method_name: &str
) -> AsyncCallBuilder<'agent, 'canister>
pub fn update_<'canister: 'agent>(
&'canister self,
method_name: &str
) -> AsyncCallBuilder<'agent, 'canister>
Create an AsyncCallBuilder to do an update call.
sourcepub fn query_<'canister: 'agent>(
&'canister self,
method_name: &str
) -> SyncCallBuilder<'agent, 'canister>
pub fn query_<'canister: 'agent>(
&'canister self,
method_name: &str
) -> SyncCallBuilder<'agent, 'canister>
Create a SyncCallBuilder to do a query call.
sourcepub async fn wait<'canister: 'agent, W>(
&'canister self,
request_id: RequestId,
waiter: W,
disable_range_check: bool
) -> Result<Vec<u8>, AgentError>where
W: Waiter,
pub async fn wait<'canister: 'agent, W>(
&'canister self,
request_id: RequestId,
waiter: W,
disable_range_check: bool
) -> Result<Vec<u8>, AgentError>where
W: Waiter,
Call request_status on the RequestId in a loop and return the response as a byte vector.
sourcepub fn clone_with_(&self, id: Principal) -> Self
pub fn clone_with_(&self, id: Principal) -> Self
Creates a copy of this canister, changing the canister ID to the provided principal.
Trait Implementations
sourceimpl<'agent> Clone for HttpRequestCanister<'agent>
impl<'agent> Clone for HttpRequestCanister<'agent>
sourcefn clone(&self) -> HttpRequestCanister<'agent>
fn clone(&self) -> HttpRequestCanister<'agent>
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more