1
0
mirror of https://github.com/actix/actix-website synced 2025-02-22 20:23:18 +01:00

updates Getting Started.

This commit is contained in:
Cameron Dershem 2019-06-18 16:44:43 -04:00
parent d762e83e74
commit 471d21b618
3 changed files with 9 additions and 10 deletions

View File

@ -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" >}}

View File

@ -1,6 +1,7 @@
[package]
name = "getting-started"
version = "0.7.0"
edition = "2018"
workspace = "../"
[dependencies]

View File

@ -1,8 +1,7 @@
// <setup>
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!")
}
// </setup>