mirror of
https://github.com/fafhrd91/actix-web
synced 2025-06-25 06:39:22 +02:00
simplify StaticFiles
This commit is contained in:
@ -129,7 +129,7 @@ fn main() {
|
||||
io::Error::new(io::ErrorKind::Other, "test"), StatusCode::OK)
|
||||
}))
|
||||
// static files
|
||||
.handler("/static/", fs::StaticFiles::new("../static/", true))
|
||||
.handler("/static/", fs::StaticFiles::new("../static/"))
|
||||
// redirect
|
||||
.resource("/", |r| r.method(Method::GET).f(|req| {
|
||||
println!("{:?}", req);
|
||||
|
@ -199,7 +199,7 @@ fn main() {
|
||||
// websocket
|
||||
.resource("/ws/", |r| r.route().f(chat_route))
|
||||
// static resources
|
||||
.handler("/static/", fs::StaticFiles::new("static/", true))
|
||||
.handler("/static/", fs::StaticFiles::new("static/"))
|
||||
})
|
||||
.bind("127.0.0.1:8080").unwrap()
|
||||
.start();
|
||||
|
@ -55,7 +55,7 @@ fn main() {
|
||||
// websocket route
|
||||
.resource("/ws/", |r| r.method(http::Method::GET).f(ws_index))
|
||||
// static files
|
||||
.handler("/", fs::StaticFiles::new("../static/", true)
|
||||
.handler("/", fs::StaticFiles::new("../static/")
|
||||
.index_file("index.html")))
|
||||
// start http server on 127.0.0.1:8080
|
||||
.bind("127.0.0.1:8080").unwrap()
|
||||
|
Reference in New Issue
Block a user