pub struct WebHandle;
Expand description
Struct which manages and sends web requests asynchronously
Implementations§
Source§impl WebHandle
impl WebHandle
Sourcepub async fn make_web_request<R, M, S>(
uri: R,
method: M,
params: S,
headers: &HeaderMap,
) -> Result<Response, Error>
pub async fn make_web_request<R, M, S>( uri: R, method: M, params: S, headers: &HeaderMap, ) -> Result<Response, Error>
Asynchronously sends a HTTP Request requiring manual parameters which returns a Response
§Example
use studentvue::request::WebHandle;
use reqwest::{
header::HeaderMap,
Method,
};
#[tokio::main]
async fn main() -> Result<(), reqwest::Error> {
let params: Vec<&str> = Vec::new();
let req = WebHandle::make_web_request("https://www.google.com", Method::POST, params, &HeaderMap::new())
.await?;
println!("{:?}", req.status());
Ok(())
}
Sourcepub async fn send(
uri: impl AsRef<str>,
params: impl Serialize,
) -> Result<String, Error>
pub async fn send( uri: impl AsRef<str>, params: impl Serialize, ) -> Result<String, Error>
Asynchronously sends a POST request to the corresponding WebService endpoint or an optional url with specified parameters
§Example
use studentvue::request::WebHandle;
#[tokio::main]
async fn main() -> Result<(), reqwest::Error> {
let res = WebHandle::send("https://afsd.edupoint.com/Service/PXPCommunication.asmx/ProcessWebServiceRequest", &[("key", "value")])
.await?;
Ok(())
}
Trait Implementations§
Auto Trait Implementations§
impl Freeze for WebHandle
impl RefUnwindSafe for WebHandle
impl Send for WebHandle
impl Sync for WebHandle
impl Unpin for WebHandle
impl UnwindSafe for WebHandle
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