mirror of
https://github.com/actix/actix-website
synced 2025-01-22 16:15:56 +01:00
Update getting-started
This commit is contained in:
parent
37bd5e5da2
commit
e018ce4278
@ -5,4 +5,5 @@ edition = "2018"
|
|||||||
workspace = "../"
|
workspace = "../"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
actix-web = "1.0"
|
actix-web = "2.0"
|
||||||
|
actix-rt = "1.0"
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
// <setup>
|
// <setup>
|
||||||
use actix_web::{web, App, HttpResponse, HttpServer, Responder};
|
use actix_web::{web, App, HttpResponse, HttpServer, Responder};
|
||||||
|
|
||||||
fn index() -> impl Responder {
|
async fn index() -> impl Responder {
|
||||||
HttpResponse::Ok().body("Hello world!")
|
HttpResponse::Ok().body("Hello world!")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn index2() -> impl Responder {
|
async fn index2() -> impl Responder {
|
||||||
HttpResponse::Ok().body("Hello world again!")
|
HttpResponse::Ok().body("Hello world again!")
|
||||||
}
|
}
|
||||||
// </setup>
|
// </setup>
|
||||||
@ -14,21 +14,21 @@ fn index2() -> impl Responder {
|
|||||||
use actix_web::get;
|
use actix_web::get;
|
||||||
|
|
||||||
#[get("/hello")]
|
#[get("/hello")]
|
||||||
fn index3() -> impl Responder {
|
async fn index3() -> impl Responder {
|
||||||
HttpResponse::Ok().body("Hey there!")
|
HttpResponse::Ok().body("Hey there!")
|
||||||
}
|
}
|
||||||
// </macro-attributes>
|
// </macro-attributes>
|
||||||
|
|
||||||
// <main>
|
// <main>
|
||||||
fn main() {
|
#[actix_rt::main]
|
||||||
|
async fn main() -> std::io::Result<()> {
|
||||||
HttpServer::new(|| {
|
HttpServer::new(|| {
|
||||||
App::new()
|
App::new()
|
||||||
.route("/", web::get().to(index))
|
.route("/", web::get().to(index))
|
||||||
.route("/again", web::get().to(index2))
|
.route("/again", web::get().to(index2))
|
||||||
})
|
})
|
||||||
.bind("127.0.0.1:8088")
|
.bind("127.0.0.1:8088")?
|
||||||
.unwrap()
|
|
||||||
.run()
|
.run()
|
||||||
.unwrap();
|
.await
|
||||||
}
|
}
|
||||||
// </main>
|
// </main>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user