pub struct IncludeConfig { /* private fields */ }Expand description
Configuration for including a router with overrides.
When including a router in an app or another router, this config allows overriding or prepending settings to the included router.
§Merge Rules (per FastAPI spec)
- prefix: Prepended to router’s prefix
- tags: Prepended to router’s tags
- dependencies: Prepended to router’s dependencies
- responses: Merged (route > router > config)
- deprecated: Override if provided
- include_in_schema: Override if provided
§Example
ⓘ
let config = IncludeConfig::new()
.prefix("/api/v1")
.tags(vec!["api"])
.dependency(auth_dep);
let app = App::builder()
.include_router_with_config(router, config)
.build();Implementations§
Source§impl IncludeConfig
impl IncludeConfig
Sourcepub fn prefix(self, prefix: impl Into<String>) -> Self
pub fn prefix(self, prefix: impl Into<String>) -> Self
Sets the prefix to prepend to the router’s prefix.
Sets the tags to prepend to the router’s tags.
Sourcepub fn dependency(self, dep: RouterDependency) -> Self
pub fn dependency(self, dep: RouterDependency) -> Self
Adds a dependency to prepend.
Sourcepub fn dependencies(self, deps: Vec<RouterDependency>) -> Self
pub fn dependencies(self, deps: Vec<RouterDependency>) -> Self
Sets dependencies to prepend.
Sourcepub fn response(self, status_code: u16, def: ResponseDef) -> Self
pub fn response(self, status_code: u16, def: ResponseDef) -> Self
Adds a response definition.
Sourcepub fn responses(self, responses: HashMap<u16, ResponseDef>) -> Self
pub fn responses(self, responses: HashMap<u16, ResponseDef>) -> Self
Sets response definitions.
Sourcepub fn deprecated(self, deprecated: bool) -> Self
pub fn deprecated(self, deprecated: bool) -> Self
Sets the deprecated override.
Sourcepub fn include_in_schema(self, include: bool) -> Self
pub fn include_in_schema(self, include: bool) -> Self
Sets the include_in_schema override.
Sourcepub fn get_prefix(&self) -> Option<&str>
pub fn get_prefix(&self) -> Option<&str>
Returns the prefix.
Returns the tags.
Sourcepub fn get_dependencies(&self) -> &[RouterDependency]
pub fn get_dependencies(&self) -> &[RouterDependency]
Returns the dependencies.
Sourcepub fn get_responses(&self) -> &HashMap<u16, ResponseDef>
pub fn get_responses(&self) -> &HashMap<u16, ResponseDef>
Returns the responses.
Sourcepub fn get_deprecated(&self) -> Option<bool>
pub fn get_deprecated(&self) -> Option<bool>
Returns the deprecated override.
Sourcepub fn get_include_in_schema(&self) -> Option<bool>
pub fn get_include_in_schema(&self) -> Option<bool>
Returns the include_in_schema override.
Trait Implementations§
Source§impl Clone for IncludeConfig
impl Clone for IncludeConfig
Source§fn clone(&self) -> IncludeConfig
fn clone(&self) -> IncludeConfig
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 IncludeConfig
impl Debug for IncludeConfig
Source§impl Default for IncludeConfig
impl Default for IncludeConfig
Source§fn default() -> IncludeConfig
fn default() -> IncludeConfig
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for IncludeConfig
impl !RefUnwindSafe for IncludeConfig
impl Send for IncludeConfig
impl Sync for IncludeConfig
impl Unpin for IncludeConfig
impl !UnwindSafe for IncludeConfig
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).