-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Disallow registering things multiple times
Update the following to thrown an error if a duplicate resource is registered: - Worker service builder -- disallow duplicate workers or periodic jobs from being registered - Http service builder -- disallow duplicate middleware or initializers from being registered. Note: Axum's built-in behavior is to disallow duplicate routes, so we don't need to handle that ourselves. - Service registry -- disallow duplicate services from being registered. Note: we may want to allow this in the future -- it _may_ be useful, but will wait until we get a feature request for this before allowing it by default.
- Loading branch information
1 parent
3a9e9e8
commit dece541
Showing
8 changed files
with
85 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,16 @@ | ||
use crate::app_context::AppContext; | ||
use crate::service::http::initializer::normalize_path::NormalizePathInitializer; | ||
use crate::service::http::initializer::Initializer; | ||
use std::collections::BTreeMap; | ||
|
||
pub fn default_initializers<S>() -> Vec<Box<dyn Initializer<S>>> { | ||
vec![Box::new(NormalizePathInitializer)] | ||
pub fn default_initializers<S>( | ||
context: &AppContext, | ||
state: &S, | ||
) -> BTreeMap<String, Box<dyn Initializer<S>>> { | ||
let initializers: Vec<Box<dyn Initializer<S>>> = vec![Box::new(NormalizePathInitializer)]; | ||
initializers | ||
.into_iter() | ||
.filter(|initializer| initializer.enabled(context, state)) | ||
.map(|initializer| (initializer.name(), initializer)) | ||
.collect() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters