1
0
mirror of https://github.com/actix/actix-website synced 2025-02-23 20:53:01 +01:00

35 lines
663 B
Rust
Raw Normal View History

2018-05-23 23:25:51 +02:00
// <setup>
2019-06-28 13:31:30 -04:00
use actix_web::{web, App, HttpResponse, HttpServer, Responder};
2018-05-23 23:25:51 +02:00
fn index() -> impl Responder {
2019-06-12 04:51:45 -04:00
HttpResponse::Ok().body("Hello world!")
2018-05-23 23:25:51 +02:00
}
2019-06-28 13:31:30 -04:00
fn index2() -> impl Responder {
HttpResponse::Ok().body("Hello world again!")
}
2018-05-23 23:25:51 +02:00
// </setup>
2019-06-12 04:56:59 -04:00
2019-08-06 01:30:50 +02:00
// <macro-attributes>
use actix_web::get;
2019-08-06 01:30:50 +02:00
#[get("/hello")]
fn index3() -> impl Responder {
2019-08-06 01:30:50 +02:00
HttpResponse::Ok().body("Hey there!")
}
2019-08-06 01:30:50 +02:00
// </macro-attributes>
2018-05-23 23:25:51 +02:00
// <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();
2018-05-23 23:25:51 +02:00
}
// </main>