mirror of
https://github.com/fafhrd91/actix-web
synced 2025-06-25 06:39:22 +02:00
refactor RouteHandler trait
This commit is contained in:
@ -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");
|
||||
|
@ -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();
|
||||
|
||||
|
Reference in New Issue
Block a user