pub struct DocumentFetcher { /* private fields */ }Expand description
Fetcher for JSON documents (AS metadata, JWKS, …).
Validates the URL through [crate::transport::validate_fetch_url], honours
the configured timeout / SSRF policy, enforces a max_size body limit, and
parses the response body as JSON.
Implementations§
Source§impl DocumentFetcher
impl DocumentFetcher
Sourcepub const DEFAULT_METADATA_MAX_BYTES: u64 = 131_072
pub const DEFAULT_METADATA_MAX_BYTES: u64 = 131_072
Default size cap for AS metadata documents (128 KB).
Sourcepub const DEFAULT_JWKS_MAX_BYTES: u64 = 65_536
pub const DEFAULT_JWKS_MAX_BYTES: u64 = 65_536
Default size cap for JWKS documents (64 KB).
Sourcepub fn new(
url: impl Into<String>,
document_type: impl Into<String>,
settings: FetchSettings,
max_size: u64,
) -> Result<Self, AuthplaneError>
pub fn new( url: impl Into<String>, document_type: impl Into<String>, settings: FetchSettings, max_size: u64, ) -> Result<Self, AuthplaneError>
Build a fetcher from a brand new HTTP client.
Sourcepub fn with_client(
url: impl Into<String>,
document_type: impl Into<String>,
settings: FetchSettings,
max_size: u64,
http: Arc<Client>,
) -> Self
pub fn with_client( url: impl Into<String>, document_type: impl Into<String>, settings: FetchSettings, max_size: u64, http: Arc<Client>, ) -> Self
Build a fetcher reusing an existing HTTP client (e.g. shared with
AuthplaneClient).
Sourcepub fn document_type(&self) -> &str
pub fn document_type(&self) -> &str
Document type label (used in errors / logs).
Sourcepub async fn fetch(&self) -> Result<FetchResult, AuthplaneError>
pub async fn fetch(&self) -> Result<FetchResult, AuthplaneError>
Perform a fetch, returning the parsed JSON body and the absolute expiry timestamp derived from cache headers (if any).
Trait Implementations§
Source§impl Clone for DocumentFetcher
impl Clone for DocumentFetcher
Auto Trait Implementations§
impl !RefUnwindSafe for DocumentFetcher
impl !UnwindSafe for DocumentFetcher
impl Freeze for DocumentFetcher
impl Send for DocumentFetcher
impl Sync for DocumentFetcher
impl Unpin for DocumentFetcher
impl UnsafeUnpin for DocumentFetcher
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