mirror of
https://github.com/actix/actix-website
synced 2025-03-28 09:48:40 +01:00
26 lines
503 B
Rust
26 lines
503 B
Rust
// <setup>
|
|
use actix_web::{web, App, HttpResponse, HttpServer, Responder};
|
|
|
|
fn index() -> impl Responder {
|
|
HttpResponse::Ok().body("Hello world!")
|
|
}
|
|
|
|
fn index2() -> impl Responder {
|
|
HttpResponse::Ok().body("Hello world again!")
|
|
}
|
|
// </setup>
|
|
|
|
// <main>
|
|
fn main() {
|
|
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>
|