actix-web
actix-web copied to clipboard
`HttpServer::new` should support asynchronous application factories
Expected Behavior
HttpServer::new should support asynchronous application factories as the argument.
Current Behavior
HttpServer::new(move || async move { ... });
fails.
Possible Solution
We either add new_async method or somehow make new work for both sync and async (if possible).
Context
I tried to allocate a thread object whose allocator uses an async method. It failed and now I don't know what to do.
Your Environment
- Rust Version: 1.58.1
- Actix Web Version: 4.0.0-rc.1
There's been some work on this here #2413; it's something the team definitely wants to see.
For now, you can use the data_factory to initialize on workers' thread. Example.