1
0
mirror of https://github.com/actix/actix-website synced 2024-11-30 19:14:36 +01:00
actix-website/examples/url-dispatch/src/norm.rs

24 lines
478 B
Rust
Raw Normal View History

2020-09-12 17:21:54 +02:00
#![allow(dead_code)]
2018-05-24 19:13:55 +02:00
// <norm>
2019-06-28 19:31:30 +02:00
use actix_web::{middleware, HttpResponse};
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
}
2020-09-12 17:21:54 +02:00
#[actix_web::main]
2019-12-28 20:10:02 +01:00
async fn main() -> std::io::Result<()> {
2019-06-28 19:31:30 +02:00
use actix_web::{web, App, HttpServer};
2019-06-26 00:20:36 +02:00
HttpServer::new(|| {
App::new()
2020-09-12 17:21:54 +02:00
.wrap(middleware::NormalizePath::default())
2019-06-26 00:20:36 +02:00
.route("/resource/", web::to(index))
})
2022-02-26 04:56:24 +01:00
.bind(("127.0.0.1", 8080))?
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
}
2019-06-26 00:20:36 +02:00
// </norm>