1
0
mirror of https://github.com/actix/actix-website synced 2025-02-02 12:19:04 +01:00

24 lines
523 B
Rust
Raw Normal View History

2019-06-28 13:31:30 -04:00
use actix_web::HttpResponse;
2020-09-12 16:21:54 +01:00
#[get("/resource/")]
2019-06-28 13:31:30 -04:00
fn index() -> HttpResponse {
HttpResponse::Ok().body("Hello")
}
2018-05-24 10:13:55 -07:00
// <norm>
2020-09-12 16:21:54 +01:00
use actix_web::{get, http::Method, middleware, web, App, HttpServer};
2018-05-24 10:13:55 -07:00
2020-09-12 16:21:54 +01:00
#[actix_web::main]
2019-12-29 04:10:02 +09:00
async fn main() -> std::io::Result<()> {
2019-06-25 18:20:36 -04:00
HttpServer::new(|| {
App::new()
2020-09-12 16:21:54 +01:00
.wrap(middleware::NormalizePath::default())
.service(index)
2019-06-25 18:20:36 -04:00
.default_service(web::route().method(Method::GET))
})
2020-09-12 16:21:54 +01:00
.bind("127.0.0.1:8080")?
2019-06-25 18:20:36 -04:00
.run()
2019-12-29 04:10:02 +09:00
.await
2018-05-24 10:13:55 -07:00
}
// </norm>