1
0
mirror of https://github.com/actix/actix-website synced 2025-06-27 15:39:02 +02:00

Quick pass at url-dispatch

This commit is contained in:
Cameron Dershem
2019-06-17 02:08:42 -04:00
parent a313315a92
commit 0c268d18c1
15 changed files with 93 additions and 95 deletions

View File

@ -1,14 +1,17 @@
// <default>
use actix_web::{http::Method, pred, App, HttpResponse};
use actix_web::{guard, web, App, HttpRequest, HttpResponse, Responder};
fn index(_req: HttpRequest) -> impl Responder {
"Welcome!"
}
// <default>
fn main() {
App::new()
.default_resource(|r| {
r.method(Method::GET).f(|req| HttpResponse::NotFound());
r.route()
.filter(pred::Not(pred::Get()))
.f(|req| HttpResponse::MethodNotAllowed());
})
.finish();
.service(web::resource("/").route(web::get().to(index)))
.default_service(
web::route()
.guard(guard::Not(guard::Get()))
.to(|| HttpResponse::MethodNotAllowed()),
);
}
// </default>