Add Router::reset_fallback

This commit is contained in:
Jonas Platte 2025-04-24 08:47:17 +02:00
parent 9c9cbb5c5f
commit ef60f855ce
2 changed files with 19 additions and 0 deletions

View File

@ -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])

View File

@ -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);