diff --git a/content/docs/getting-started.md b/content/docs/getting-started.md index e42bb29..042a1ac 100644 --- a/content/docs/getting-started.md +++ b/content/docs/getting-started.md @@ -27,18 +27,17 @@ actix-web = "{{< actix-version "actix-web" >}}" In order to implement a web server, we first need to create a request handler. -A request handler is a function that accepts an `HttpRequest` instance as its only parameter -and returns a type that can be converted into `HttpResponse`: - -Filename: `src/main.rs` +A request handler is a function that accepts any type that can be extracted from a +request (ie, `impl FromRequest`) as its only parameter and returns a type that +can be converted into an `HttpResponse` (ie, `impl Responder`): {{< include-example example="getting-started" section="setup" >}} -Next, create an `Application` instance and register the request handler with -the application's `resource` on a particular *HTTP method* and *path* and +Next, create an `App` instance and register the request handler with +the application's `route` on a particular *HTTP method* and *path* and after that, the application instance can be used with `HttpServer` to listen for incoming connections. The server accepts a function that should return an -`HttpResponse`. +application factory. {{< include-example example="getting-started" section="main" >}} diff --git a/examples/getting-started/Cargo.toml b/examples/getting-started/Cargo.toml index ee5e823..ad77af7 100644 --- a/examples/getting-started/Cargo.toml +++ b/examples/getting-started/Cargo.toml @@ -1,6 +1,7 @@ [package] name = "getting-started" version = "0.7.0" +edition = "2018" workspace = "../" [dependencies] diff --git a/examples/getting-started/src/main.rs b/examples/getting-started/src/main.rs index f81f472..f3f4186 100644 --- a/examples/getting-started/src/main.rs +++ b/examples/getting-started/src/main.rs @@ -1,8 +1,7 @@ // -extern crate actix_web; -use actix_web::{web, App, HttpRequest, HttpResponse, HttpServer}; +use actix_web::{web, App, HttpRequest, HttpResponse, HttpServer, Responder}; -fn index(_req: HttpRequest) -> HttpResponse { +fn index(_req: HttpRequest) -> impl Responder { HttpResponse::Ok().body("Hello world!") } //