1
0
mirror of https://github.com/actix/actix-website synced 2025-02-13 00:25:35 +01:00

25 lines
623 B
Rust
Raw Normal View History

2019-06-25 18:20:36 -04:00
use actix_web::{guard, web, App, HttpRequest, HttpResponse, HttpServer, Responder};
2019-06-17 02:08:42 -04:00
2020-09-12 16:21:54 +01:00
#[allow(dead_code)]
2019-12-29 04:10:02 +09:00
async fn index(_req: HttpRequest) -> impl Responder {
2019-06-17 02:08:42 -04:00
"Welcome!"
}
2018-05-24 10:13:55 -07:00
2019-06-17 02:08:42 -04:00
// <default>
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()
.service(web::resource("/").route(web::get().to(index)))
.default_service(
web::route()
.guard(guard::Not(guard::Get()))
2022-02-26 03:56:24 +00:00
.to(HttpResponse::MethodNotAllowed),
2019-06-25 18:20:36 -04:00
)
})
2022-02-26 03:56:24 +00: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
}
// </default>