github_webhooks/axum/headers/
event.rs1use headers::{Header, HeaderName, HeaderValue};
2
3pub static X_GITHUB_EVENT: HeaderName = HeaderName::from_static("x-github-event");
5
6pub struct XGithubEvent(pub String);
16
17impl Header for XGithubEvent {
18 fn name() -> &'static HeaderName {
19 &X_GITHUB_EVENT
20 }
21
22 fn decode<'i, I>(values: &mut I) -> Result<Self, headers::Error>
23 where
24 I: Iterator<Item = &'i HeaderValue>,
25 {
26 let value = values
27 .next()
28 .and_then(|h| HeaderValue::to_str(h).ok())
29 .and_then(|s| Some(s.to_string()))
30 .ok_or_else(headers::Error::invalid)?;
32
33 Ok(Self(value))
34 }
35
36 fn encode<E>(&self, _values: &mut E)
37 where
38 E: Extend<HeaderValue>,
39 {
40 unreachable!()
42 }
43}