1
0
mirror of https://github.com/actix/actix-website synced 2025-06-27 07:29:02 +02:00

Intro: done-ish. Getting Started: done-ish. Application: done-ish.

This commit is contained in:
Cameron Dershem
2019-06-19 18:00:31 -04:00
parent da969fed1f
commit ea7bc84f8d
11 changed files with 145 additions and 66 deletions

View File

@ -1,17 +1,25 @@
// <setup>
use actix_web::{web, App, HttpRequest, HttpResponse, HttpServer, Responder};
fn index(_req: HttpRequest) -> impl Responder {
fn index() -> impl Responder {
HttpResponse::Ok().body("Hello world!")
}
fn index2(_req: HttpRequest) -> impl Responder {
HttpResponse::Ok().body("Hello world again!")
}
// </setup>
// <main>
fn main() {
HttpServer::new(|| App::new().route("/", web::get().to(index)))
.bind("127.0.0.1:8088")
.unwrap()
.run()
.unwrap();
HttpServer::new(|| {
App::new()
.route("/", web::get().to(index))
.route("/again", web::get().to(index2))
})
.bind("127.0.0.1:8088")
.unwrap()
.run()
.unwrap();
}
// </main>