Implements RouterBuilder

This commit is contained in:
2024-02-25 02:25:55 -03:00
parent b8b8d5713f
commit d4bd9c6c5e
4 changed files with 29 additions and 6 deletions

View File

@@ -0,0 +1,22 @@
use axum::Router;
pub struct RouterBuilder {
router: Router,
}
impl RouterBuilder {
pub fn new() -> Self {
RouterBuilder {
router: Router::new(),
}
}
pub fn add_config(&mut self, config_fn: fn(Router) -> Router) -> &mut Self {
self.router = config_fn(self.router.clone());
return self;
}
pub fn build(&self) -> Router {
self.router.clone()
}
}