mirror of
https://github.com/actix/actix-website
synced 2025-06-27 07:29:02 +02:00
begin update of docs to actix-web 1.0
This commit is contained in:
@ -4,4 +4,4 @@ version = "0.7.0"
|
||||
workspace = "../"
|
||||
|
||||
[dependencies]
|
||||
actix-web = "0.7"
|
||||
actix-web = "1.0"
|
||||
|
@ -1,16 +1,34 @@
|
||||
// // <setup>
|
||||
// extern crate actix_web;
|
||||
// use actix_web::{server, App, HttpRequest};
|
||||
|
||||
// fn index(_req: &HttpRequest) -> &'static str {
|
||||
// "Hello world!"
|
||||
// }
|
||||
// // </setup>
|
||||
// // <main>
|
||||
// fn main() {
|
||||
// server::new(|| App::new().resource("/", |r| r.f(index)))
|
||||
// .bind("127.0.0.1:8088")
|
||||
// .unwrap()
|
||||
// .run();
|
||||
// }
|
||||
// // </main>
|
||||
|
||||
// <setup>
|
||||
extern crate actix_web;
|
||||
use actix_web::{server, App, HttpRequest};
|
||||
use actix_web::{web, App, HttpRequest, HttpResponse, HttpServer};
|
||||
|
||||
fn index(_req: &HttpRequest) -> &'static str {
|
||||
"Hello world!"
|
||||
fn index(_req: HttpRequest) -> HttpResponse {
|
||||
HttpResponse::Ok().body("Hello world!")
|
||||
}
|
||||
// </setup>
|
||||
// <main>
|
||||
fn main() {
|
||||
server::new(|| App::new().resource("/", |r| r.f(index)))
|
||||
.bind("127.0.0.1:8088")
|
||||
HttpServer::new(|| App::new().service(web::resource("/").to(index)))
|
||||
.bind("127.0.0.1:8000")
|
||||
.unwrap()
|
||||
.run();
|
||||
.run()
|
||||
.unwrap();
|
||||
}
|
||||
// </main>
|
||||
|
Reference in New Issue
Block a user