pub struct ApiVersionLayer<const N: usize, F> { /* private fields */ }
Expand description
Axum middleware to rewrite a request such that a version prefix is added to the path. This is
based on a set of versions and an optional "x-api-version"
custom HTTP header: if no such
header is present, the highest version is used. Yet this only applies to requests the URIs of
which pass a filter; others are not rewritten.
Paths must not start with a version prefix, e.g. "/v0"
.
Implementations§
Source§impl<const N: usize, F> ApiVersionLayer<N, F>
impl<const N: usize, F> ApiVersionLayer<N, F>
Sourcepub fn new(
versions: [u16; N],
filter: F,
) -> Result<Self, NewApiVersionLayerError>
pub fn new( versions: [u16; N], filter: F, ) -> Result<Self, NewApiVersionLayerError>
Create a new ApiVersionLayer.
The given versions must not be empty and must be strictly monotonically increasing, e.g.
[0, 1, 2]
.
Trait Implementations§
Source§impl<const N: usize, F: Clone> Clone for ApiVersionLayer<N, F>
impl<const N: usize, F: Clone> Clone for ApiVersionLayer<N, F>
Source§fn clone(&self) -> ApiVersionLayer<N, F>
fn clone(&self) -> ApiVersionLayer<N, F>
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl<const N: usize, S, F> Layer<S> for ApiVersionLayer<N, F>where
F: ApiVersionFilter,
impl<const N: usize, S, F> Layer<S> for ApiVersionLayer<N, F>where
F: ApiVersionFilter,
Auto Trait Implementations§
impl<const N: usize, F> Freeze for ApiVersionLayer<N, F>where
F: Freeze,
impl<const N: usize, F> RefUnwindSafe for ApiVersionLayer<N, F>where
F: RefUnwindSafe,
impl<const N: usize, F> Send for ApiVersionLayer<N, F>where
F: Send,
impl<const N: usize, F> Sync for ApiVersionLayer<N, F>where
F: Sync,
impl<const N: usize, F> Unpin for ApiVersionLayer<N, F>where
F: Unpin,
impl<const N: usize, F> UnwindSafe for ApiVersionLayer<N, F>where
F: UnwindSafe,
Blanket Implementations§
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
Mutably borrows from an owned value. Read more