From 52ba8ea7774009f7919a8d2c48f619af3f8743fb Mon Sep 17 00:00:00 2001 From: philpill Date: Sat, 24 Sep 2022 13:24:35 +0100 Subject: [PATCH] Clarify main.rs in Getting Started (#232) (#287) Co-authored-by: philpill --- docs/getting-started.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/getting-started.md b/docs/getting-started.md index 6561b1f..0c3ea7a 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -35,12 +35,16 @@ actix-web = "${actixWebMajorVersion}"`} Request handlers use async functions that accept zero or more parameters. These parameters can be extracted from a request (see `FromRequest` trait) and returns a type that can be converted into an `HttpResponse` (see `Responder` trait): +Replace the contents of `src/main.rs` with the following: + Notice that some of these handlers have routing information attached directly using the built-in macros. These allow you to specify the method and path that the handler should respond to. You will see below how to register `manual_hello` (i.e. routes that do not use a routing macro). Next, create an `App` instance and register the request handlers. Use `App::service` for the handlers using routing macros and `App::route` for manually routed handlers, declaring the path and method. Finally, the app is started inside an `HttpServer` which will serve incoming requests using your `App` as an "application factory". +Further append the following `main` function to `src/main.rs`: + That's it! Compile and run the program with `cargo run`. The `#[actix_web::main]` macro executes the async main function within the actix runtime. Now you can go to `http://127.0.0.1:8080/` or any of the other routes you defined to see the results.