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:
@ -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>
|
||||
|
Reference in New Issue
Block a user