pub struct VersionConfig {
pub strategy: VersionStrategy,
pub current_version: u32,
pub supported_versions: Vec<u32>,
pub deprecated_versions: Vec<u32>,
pub version_header: String,
pub deprecation_header: String,
}Expand description
Configuration for API versioning.
Fields§
§strategy: VersionStrategyHow to extract the version.
current_version: u32The current (latest) version.
supported_versions: Vec<u32>All supported versions.
deprecated_versions: Vec<u32>Deprecated versions (still work, but emit a warning header).
version_header: StringHeader name for the Header strategy.
deprecation_header: StringHeader added to responses for deprecated versions.
Implementations§
Source§impl VersionConfig
impl VersionConfig
Sourcepub fn strategy(self, strategy: VersionStrategy) -> Self
pub fn strategy(self, strategy: VersionStrategy) -> Self
Set the versioning strategy.
Sourcepub fn deprecated(self, versions: &[u32]) -> Self
pub fn deprecated(self, versions: &[u32]) -> Self
Set deprecated versions.
Sourcepub fn version_header(self, name: impl Into<String>) -> Self
pub fn version_header(self, name: impl Into<String>) -> Self
Set the version header name.
Sourcepub fn is_supported(&self, version: &ApiVersion) -> bool
pub fn is_supported(&self, version: &ApiVersion) -> bool
Check if a version is supported.
Sourcepub fn is_deprecated(&self, version: &ApiVersion) -> bool
pub fn is_deprecated(&self, version: &ApiVersion) -> bool
Check if a version is deprecated.
Sourcepub fn extract_from_path(&self, path: &str) -> Option<ApiVersion>
pub fn extract_from_path(&self, path: &str) -> Option<ApiVersion>
Extract version from a request path (URL prefix strategy).
Sourcepub fn extract_from_header(&self, value: &str) -> Option<ApiVersion>
pub fn extract_from_header(&self, value: &str) -> Option<ApiVersion>
Extract version from a header value.
Sourcepub fn deprecation_warning(&self, version: &ApiVersion) -> Option<String>
pub fn deprecation_warning(&self, version: &ApiVersion) -> Option<String>
Generate deprecation warning header value for a deprecated version.
Trait Implementations§
Source§impl Clone for VersionConfig
impl Clone for VersionConfig
Source§fn clone(&self) -> VersionConfig
fn clone(&self) -> VersionConfig
Returns a duplicate 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 Debug for VersionConfig
impl Debug for VersionConfig
Auto Trait Implementations§
impl Freeze for VersionConfig
impl RefUnwindSafe for VersionConfig
impl Send for VersionConfig
impl Sync for VersionConfig
impl Unpin for VersionConfig
impl UnwindSafe for VersionConfig
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, _span: NoopSpan) -> Self
fn instrument(self, _span: NoopSpan) -> Self
Instruments this future with a span (no-op when disabled).
Source§fn in_current_span(self) -> Self
fn in_current_span(self) -> Self
Instruments this future with the current span (no-op when disabled).