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 = "../"
|
||||
|
||||
[dependencies]
|
||||
actix-web = "1.0"
|
||||
actix-web = "2.0"
|
||||
actix-rt = "1.0"
|
||||
|
@ -1,11 +1,11 @@
|
||||
// <setup>
|
||||
use actix_web::{web, App, HttpResponse, HttpServer, Responder};
|
||||
|
||||
fn index() -> impl Responder {
|
||||
async fn index() -> impl Responder {
|
||||
HttpResponse::Ok().body("Hello world!")
|
||||
}
|
||||
|
||||
fn index2() -> impl Responder {
|
||||
async fn index2() -> impl Responder {
|
||||
HttpResponse::Ok().body("Hello world again!")
|
||||
}
|
||||
// </setup>
|
||||
@ -14,21 +14,21 @@ fn index2() -> impl Responder {
|
||||
use actix_web::get;
|
||||
|
||||
#[get("/hello")]
|
||||
fn index3() -> impl Responder {
|
||||
async fn index3() -> impl Responder {
|
||||
HttpResponse::Ok().body("Hey there!")
|
||||
}
|
||||
// </macro-attributes>
|
||||
|
||||
// <main>
|
||||
fn main() {
|
||||
#[actix_rt::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
HttpServer::new(|| {
|
||||
App::new()
|
||||
.route("/", web::get().to(index))
|
||||
.route("/again", web::get().to(index2))
|
||||
})
|
||||
.bind("127.0.0.1:8088")
|
||||
.unwrap()
|
||||
.bind("127.0.0.1:8088")?
|
||||
.run()
|
||||
.unwrap();
|
||||
.await
|
||||
}
|
||||
// </main>
|
||||
|
Loading…
x
Reference in New Issue
Block a user