mirror of
https://github.com/tokio-rs/axum.git
synced 2025-09-27 13:00:39 +00:00
Add Router::reset_fallback
This commit is contained in:
parent
9c9cbb5c5f
commit
ef60f855ce
@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
# Unreleased
|
||||
|
||||
- **added:** `Router::reset_fallback`
|
||||
|
||||
# 0.8.3
|
||||
|
||||
- **added:** Implement `From<Bytes>` for `Message` ([#3273])
|
||||
|
@ -381,6 +381,21 @@ where
|
||||
})
|
||||
}
|
||||
|
||||
/// Reset the fallback to its default.
|
||||
///
|
||||
/// Useful to merge two routers with fallbacks, as [`merge`] doesn't allow
|
||||
/// both routers to have an explicit fallback. Use this method to remove the
|
||||
/// one you want to discard before merging.
|
||||
///
|
||||
/// [`merge`]: Self::merge
|
||||
pub fn reset_fallback(self) -> Self {
|
||||
tap_inner!(self, mut this => {
|
||||
this.fallback_router = PathRouter::new_fallback();
|
||||
this.default_fallback = true;
|
||||
this.catch_all_fallback = Fallback::Default(Route::new(NotFound));
|
||||
})
|
||||
}
|
||||
|
||||
fn fallback_endpoint(self, endpoint: Endpoint<S>) -> Self {
|
||||
tap_inner!(self, mut this => {
|
||||
this.fallback_router.set_fallback(endpoint);
|
||||
|
Loading…
x
Reference in New Issue
Block a user