pub struct AcceptLayer { /* private fields */ }Expand description
Rejects requests with no acceptable Accept media type with a 406 JSON:API
error document (via crate::request::negotiate).
On success the negotiated JsonApiMediaType
is inserted into the request’s extensions. A handler that wants the response
Content-Type to reflect negotiated ext/profile must read it from there
(e.g. axum::Extension<JsonApiMediaType>) and pass it on — a responder’s
IntoResponse cannot see the request, so it cannot apply it automatically.
The layer is configured with the server’s advertised extensions/profiles via
AcceptLayer::ext / AcceptLayer::profile.
Implementations§
Source§impl AcceptLayer
impl AcceptLayer
Sourcepub fn new() -> AcceptLayer
pub fn new() -> AcceptLayer
Create a new accept-negotiation layer advertising no extensions or
profiles (plain application/vnd.api+json).
Sourcepub fn ext(
self,
uris: impl IntoIterator<Item = impl Into<String>>,
) -> AcceptLayer
pub fn ext( self, uris: impl IntoIterator<Item = impl Into<String>>, ) -> AcceptLayer
Advertise the extension URIs this server supports.
Sourcepub fn profile(
self,
uris: impl IntoIterator<Item = impl Into<String>>,
) -> AcceptLayer
pub fn profile( self, uris: impl IntoIterator<Item = impl Into<String>>, ) -> AcceptLayer
Advertise the profile URIs this server supports.
Trait Implementations§
Source§impl Clone for AcceptLayer
impl Clone for AcceptLayer
Source§fn clone(&self) -> AcceptLayer
fn clone(&self) -> AcceptLayer
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more