pub struct StaticAgentCardHandler { /* private fields */ }Expand description
Serves a pre-serialized AgentCard as a JSON HTTP response with caching.
Implementations§
Source§impl StaticAgentCardHandler
impl StaticAgentCardHandler
Sourcepub fn new(card: &AgentCard) -> Result<StaticAgentCardHandler, ServerError>
pub fn new(card: &AgentCard) -> Result<StaticAgentCardHandler, ServerError>
Creates a new handler by serializing the given AgentCard to JSON.
Computes an ETag from the serialized content and sets Last-Modified
to the time the running executable was last modified, so every replica
of one build sends the same date (audit E-F22: it was the time each
process started, so a fleet’s replicas disagreed and an
If-Modified-Since revalidation missed on all but the replica that
issued the date). Where that time cannot be read, or is in the future, it
is the time of construction. with_last_modified
sets it explicitly, for instance to the card file’s own modification time.
§Errors
ServerError::InvalidParams
if the card is not one a server may publish (AgentCard::validate,
AgentCard::validate_security_schemes), as build(), hot reload
and the dynamic handler refuse it; until 2026-10-13 a card handed to
this handler directly was served unchecked. Another
ServerError if serialization fails.
Sourcepub fn with_last_modified(self, time: SystemTime) -> StaticAgentCardHandler
pub fn with_last_modified(self, time: SystemTime) -> StaticAgentCardHandler
Sets Last-Modified to time instead of the executable’s modification
time, for a card whose real modification date is known (its file’s, or
the release’s). A time in the future is sent as given: this does not
second-guess the caller.
Sourcepub const fn with_max_age(self, seconds: u32) -> StaticAgentCardHandler
pub const fn with_max_age(self, seconds: u32) -> StaticAgentCardHandler
Sets the Cache-Control max-age in seconds.
Sourcepub fn handle(&self, req: &Request<impl Body>) -> Response<Full<Bytes>>
pub fn handle(&self, req: &Request<impl Body>) -> Response<Full<Bytes>>
Handles an agent card request, returning a cached response.
Supports conditional requests via If-None-Match and If-Modified-Since
headers, returning 304 Not Modified when appropriate. A method other
than GET or HEAD is 405 Method Not Allowed with
Allow: GET, HEAD, never 412, whatever its preconditions
(RFC 9110 §13.2.1).
Sourcepub fn handle_unconditional(&self) -> Response<Full<Bytes>>
pub fn handle_unconditional(&self) -> Response<Full<Bytes>>
Handles a request without conditional headers (legacy compatibility).
Trait Implementations§
Source§impl Clone for StaticAgentCardHandler
impl Clone for StaticAgentCardHandler
Source§fn clone(&self) -> StaticAgentCardHandler
fn clone(&self) -> StaticAgentCardHandler
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !Freeze for StaticAgentCardHandler
impl Forget for StaticAgentCardHandler
impl Move for StaticAgentCardHandler
impl RefUnwindSafe for StaticAgentCardHandler
impl Send for StaticAgentCardHandler
impl Sync for StaticAgentCardHandler
impl Unpin for StaticAgentCardHandler
impl UnsafeUnpin for StaticAgentCardHandler
impl UnwindSafe for StaticAgentCardHandler
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].