Implemented some functionality which will allow the service configuration of the app to be split among the features for readability and testability.
17 lines
323 B
Rust
17 lines
323 B
Rust
use actix_web::App;
|
|
|
|
pub trait ServiceBuilder<T> {
|
|
fn add_feature<F>(self, f: F) -> App<T>
|
|
where
|
|
F: Fn(App<T>) -> App<T>;
|
|
}
|
|
|
|
impl<T> ServiceBuilder<T> for App<T> {
|
|
fn add_feature<F>(self, create_feature: F) -> App<T>
|
|
where
|
|
F: Fn(App<T>) -> App<T>,
|
|
{
|
|
create_feature(self)
|
|
}
|
|
}
|