Simplify type for actix_web::App?
- Langage dominant
- Rust
- Étoiles
- 24.8k
- Forks
- 1.9k
- Merge moyen
- 23 h 10 min
- PR mergées (30 j)
- 26
Description
I'm trying to write a function that builds my app, that way it can be reused between my `main` function and my tests. Unfortunate, the type parameters for `actix_web::App` or the `IntoServiceFactory` traits are incredibly verbose. Ideally doing something like this would be straightforward:
```rust
fn create_app() -> actix_web::App {
let templates = tera::Tera::new("templates/*").unwrap();
actix_web::App::new()
.data(AppState { templates })
.route("/", actix_web::web::get().to(index))
.route("/tool/", actix_web::web::post().to(tool))
}
```
I think the right solution might be a type alias that would let you do `-> impl Something`, but I'm open to suggestions on what the right way to handle this ergonomic issue are.
Guide de contribution
Ouvrir le guide de contribution
Piste de recherche
Compare the desired `fn create_app() -> actix_web::App` shape with the current `actix_web::App` and `IntoServiceFactory` APIs, using the issue's shared builder example as the starting point. Done means an agreed ergonomic approach lets the app builder be reused between `main` and tests without requiring verbose type parameters, while preserving the shown routes.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- rust
- Domaine
- backend
- Type d'issue
- Fonctionnalité
- Difficulté
- 5/5
- Temps estimé
- Plus d'une semaine
- Activité
- À l'abandon
- Clarté
- À clarifier
- Accessibilité débutants
- 25/100