Struct mangadex_api::HttpClient [−][src]
pub struct HttpClient {
pub client: Client,
pub base_url: Url,
auth_tokens: Option<AuthTokens>,
captcha: Option<String>,
}
Fields
client: Client
base_url: Url
auth_tokens: Option<AuthTokens>
captcha: Option<String>
Implementations
Create a new HttpClient
with a custom reqwest::Client
.
Get a builder struct to customize the HttpClient
fields.
Examples
use url::Url;
use mangadex_api::{MangaDexClient, HttpClient};
let http_client = HttpClient::builder()
.base_url(Url::parse("127.0.0.1:8000")?)
.build()?;
let mangadex_client = MangaDexClient::new_with_http_client(http_client);
Send the request to the endpoint but don’t deserialize the response.
This is useful to handle things such as response header data for more control over areas such as rate limiting.
pub(crate) async fn send_request<E>(&self, endpoint: &E) -> Result<E::Response> where
E: Endpoint,
<<E as Endpoint>::Response as FromResponse>::Response: DeserializeOwned,
pub(crate) async fn send_request<E>(&self, endpoint: &E) -> Result<E::Response> where
E: Endpoint,
<<E as Endpoint>::Response as FromResponse>::Response: DeserializeOwned,
Send the request to the endpoint and deserialize the response body.
Get the authentication tokens stored in the client.
Set new authentication tokens into the client.
Remove all authentication tokens from the client.
This is effectively the same as logging out, though will not remove the active session from the MangaDex server. Be sure to call the logout endpoint to ensure your session is removed.
Get the captcha solution stored in the client.
Set a new captcha solution into the client.
The code needed for this can be found in the “X-Captcha-Sitekey” header field,
or the siteKey
parameter in the error context of a 403 response,
captcha_required_exception
error code.
Remove the captcha solution from the client.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for HttpClient
impl Send for HttpClient
impl Sync for HttpClient
impl Unpin for HttpClient
impl !UnwindSafe for HttpClient
Blanket Implementations
Mutably borrows from an owned value. Read more
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more