1
0
mirror of https://github.com/actix/actix-extras.git synced 2025-06-25 09:59:21 +02:00

refactor RouteHandler trait

This commit is contained in:
Nikolay Kim
2017-11-29 13:26:55 -08:00
parent 6f833798c7
commit 16ceb741b8
8 changed files with 144 additions and 169 deletions

View File

@ -82,8 +82,15 @@ fn main() {
.header("LOCATION", "/index.html")
.body(Body::Empty)
}))
.handler("/test", |req| {
match *req.method() {
Method::GET => httpcodes::HTTPOk,
Method::POST => httpcodes::HTTPMethodNotAllowed,
_ => httpcodes::HTTPNotFound,
}
})
// static files
.route_handler("/static", StaticFiles::new("examples/static/", true)))
.route("/static", StaticFiles::new("examples/static/", true)))
.serve::<_, ()>("127.0.0.1:8080").unwrap();
println!("Started http server: 127.0.0.1:8080");

View File

@ -66,7 +66,8 @@ fn main() {
.middleware(middlewares::Logger::default())
// websocket route
.resource("/ws/", |r| r.get(ws_index))
.route_handler("/", StaticFiles::new("examples/static/", true)))
// static files
.route("/", StaticFiles::new("examples/static/", true)))
// start http server on 127.0.0.1:8080
.serve::<_, ()>("127.0.0.1:8080").unwrap();