pub fn notification_token(headers: &HeaderMap) -> Option<&str>Expand description
Reads the push notification token from a webhook request’s headers, under either spelling.
Returns None when neither header is present, when a value is not
visible ASCII, or when the request carries more than one distinct value
across the two spellings. That last case fails closed: a sender writes
one token, so two different ones mean something between the sender and
the receiver added one, and picking either would let it choose which
the receiver checks.
Compare the result against the token you registered with a constant-time comparison; it is a shared secret.
use a2a_protocol_server::push::webhook::notification_token;
let mut headers = hyper::HeaderMap::new();
headers.insert("A2A-Notification-Token", "tok-1".parse().unwrap());
assert_eq!(notification_token(&headers), Some("tok-1"));