Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't have multiple Applications on a single server with different state #49

Closed
fuchsnj opened this issue Jan 14, 2018 · 6 comments
Closed

Comments

@fuchsnj
Copy link
Contributor

fuchsnj commented Jan 14, 2018

I don't think this is currently possible, but please correct me if I'm wrong.

HttpServer::new() requires an iterator of Applications (something that implements IntoHttpHandler)

Since the Application has a generic State parameter, if you have applications with a different type for State, you can't create an iterator over these different types.

@fafhrd91
Copy link
Member

You have to manually box applications, something like:

HttpServer::new(|| vec![
       Box::new(Application::<State1>::new().finish()),
       Box::new(Application::<State2>::new().finish()),
       Box::new(Application::<State3>::new().finish())])

maybe application should have convenience method.

@fuchsnj
Copy link
Contributor Author

fuchsnj commented Jan 14, 2018

once you box the application, it doesn't implement actix_web::server::HttpHandler so I don't think this works either

the following trait bounds were not satisfied:
           `std::boxed::Box<actix_web::application::HttpApplication<State1>> : actix_web::server::HttpHandler

@fafhrd91
Copy link
Member

you are right! thanks for report

@fafhrd91
Copy link
Member

@daleione
Copy link

daleione commented Sep 18, 2018

error with app with state and no state. such like

vec![ App::new().resource("/test1", |r| r.f(test1)) .boxed(), App::with_state(AppState::default()) .resource("/test2", |r| r.f(test2)) .boxed(),

@fafhrd91
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants