actix / actix/actix-web

not using handlers declared with routing macro should be detectable

Offen
#2,696 2 Kommentare 2 Reaktionen 1 zugewiesene Person Beansprucht von @Chaostheorie Auf GitHub ansehen
A-web-codegen C-improvement good-first-issue
Vorherrschende Sprache
Rust
Sterne
24.8k
Forks
1.9k
Ø Merge
23 Std. 10 Min.
Gemergte PRs (30 T.)
26

Beschreibung

Hello,

I've been using actix-web for a while and it's working very well! There is one little thing that's been bothering me, though.
When I write services with actix-web I really like to use the macros for specifying method and path, as in the example below:
```rust
use actix_web::{get, web, App, HttpServer, Responder};

#[get("/hello/{name}")]
async fn greet(name: web::Path) -> impl Responder {
format!("Hello {name}!")
}

#[actix_web::main] // or #[tokio::main]
async fn main() -> std::io::Result<()> {
HttpServer::new(|| {
App::new().service(greet)
})
.bind(("127.0.0.1", 8080))?
.run()
.await
}
```

I think it's great to have the path and method next to the implementation of the endpoint. However, nearly every time I add a new endpoint I forget to add the `service` to the app in when setting up the server, leading to a confused developer and a 404 when testing it out :)

I am not experienced enough with Rust's macro system to know if it's actually possible to do, but it would really be great if just using the macro could somehow add the service.

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.