1
0
mirror of https://github.com/actix/actix-website synced 2024-12-04 04:31:55 +01:00
actix-website/examples/url-dispatch/src/main.rs

35 lines
624 B
Rust
Raw Normal View History

pub mod cfg;
pub mod dhandler;
2019-06-26 00:20:36 +02:00
pub mod guard;
pub mod guard2;
pub mod minfo;
pub mod norm;
pub mod norm2;
pub mod path;
pub mod path2;
pub mod pbuf;
pub mod resource;
pub mod scope;
pub mod url_ext;
pub mod urls;
2018-05-24 19:13:55 +02:00
// <main>
2019-06-26 00:20:36 +02:00
use actix_web::{web, App, HttpResponse, HttpServer};
2018-05-24 19:13:55 +02:00
2019-12-28 20:10:02 +01:00
async fn index() -> HttpResponse {
2019-06-26 00:20:36 +02:00
HttpResponse::Ok().body("Hello")
2018-05-24 19:13:55 +02:00
}
2019-12-28 20:10:02 +01:00
#[actix_rt::main]
async fn main() -> std::io::Result<()> {
2019-06-26 00:20:36 +02:00
HttpServer::new(|| {
App::new()
.route("/", web::get().to(index))
.route("/user", web::post().to(index))
})
2019-12-28 20:10:02 +01:00
.bind("127.0.0.1:8088")?
2019-06-26 00:20:36 +02:00
.run()
2019-12-28 20:10:02 +01:00
.await
2018-05-24 19:13:55 +02:00
}
// </main>