pub struct HttpApi;Expand description
HttpApi
Stable HTTP API for canic users. Enforces metrics, limits, and IC-safe defaults.
Implementations§
Source§impl HttpApi
impl HttpApi
Sourcepub async fn get<T: DeserializeOwned>(
url: &str,
headers: &[(&str, &str)],
) -> Result<T, PublicError>
pub async fn get<T: DeserializeOwned>( url: &str, headers: &[(&str, &str)], ) -> Result<T, PublicError>
Perform a GET request and deserialize a JSON response. Returns an error on non-2xx status codes or JSON decode failures.
Sourcepub async fn get_with_label<T: DeserializeOwned>(
url: &str,
headers: &[(&str, &str)],
label: &str,
) -> Result<T, PublicError>
pub async fn get_with_label<T: DeserializeOwned>( url: &str, headers: &[(&str, &str)], label: &str, ) -> Result<T, PublicError>
Same as get, with an explicit metrics label.
Returns an error on non-2xx status codes or JSON decode failures.
Sourcepub async fn get_raw(
args: HttpRequestArgs,
) -> Result<HttpRequestResult, PublicError>
pub async fn get_raw( args: HttpRequestArgs, ) -> Result<HttpRequestResult, PublicError>
Perform a raw HTTP request with metrics, returning the response verbatim.
Auto Trait Implementations§
impl Freeze for HttpApi
impl RefUnwindSafe for HttpApi
impl Send for HttpApi
impl Sync for HttpApi
impl Unpin for HttpApi
impl UnwindSafe for HttpApi
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more