-
Hi, I want to create a dynamic App but have a complime error below: type mismatch resolving I enter the warp function, it's also return the App<
impl ServiceFactory<
ServiceRequest,
Response = ServiceResponse<B>,
Error = actix_web::Error,
Config = (),
InitError = (),
>,
> My code below: fn init_app<B>() -> App<
impl ServiceFactory<
ServiceRequest,
Response = ServiceResponse<B>,
Error = actix_web::Error,
Config = (),
InitError = (),
>,
> where B: MessageBody
{
let init_db_url = PROJECT_CONFIGS.db_url.as_ref();
let pg_conn = move || PgConnection::connect2(init_db_url);
let debug_app = App::new()
.data_factory(pg_conn)
.wrap(middleware::Compress::default())
.wrap(Cors::default().allow_any_origin());
let release_app = App::new()
.data_factory(pg_conn)
.wrap(middleware::Compress::default());
#[cfg(debug_assertions)]
if cfg!(debug_assertions) {
debug_app
} else {
release_app
}
} Thanks :) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Dynamic apps are difficult for the same reason as dynamic anything is difficult in Rust. The workaround for dynamic middleware is the |
Beta Was this translation helpful? Give feedback.
Dynamic apps are difficult for the same reason as dynamic anything is difficult in Rust.
The workaround for dynamic middleware is the
Condition
middleware wrapper.