pub fn media_type(accept: Option<&str>) -> Result<&'static str>Expand description
Picks the media type to answer an Accept header with.
A missing or empty header is treated as */*, per RFC 9110. Candidates are
scored by quality value; ties go to this crate’s own preference order, which
puts SSE first because it is the interoperable default and the only fully
implemented transport here. That differs from the TypeScript encoder, which
upgrades a bare */* to protobuf.
Returns Error::UnsupportedMediaType when the header excludes everything
this build can emit — the case that deserves a 406.
assert_eq!(media_type(None).unwrap(), SSE_MEDIA_TYPE);
assert_eq!(media_type(Some("text/event-stream")).unwrap(), SSE_MEDIA_TYPE);
assert!(media_type(Some("application/xml")).is_err());