静态文件服务用不了。按照文档上的写。没有use salvo::serve_static::StaticDir;中的serve_static没有
Closed this issue · 1 comments
rongzhongyang commented
use salvo::prelude::*;
use salvo::serve_static::StaticDir; //这行报错。没有serve_static
#[tokio::main]
async fn main() {
tracing_subscriber::fmt().init();
let router = Router::with_path("<**path>").get(
StaticDir::new([
"examples/static-dir-list/static/boy",
"examples/static-dir-list/static/girl",
])
.defaults("index.html")
.auto_list(true),
);
let acceptor = TcpListener::new("127.0.0.1:5800").bind().await;
Server::new(acceptor).serve(router).await;
}
chrislearn commented
看这里,你需要打开对应的 feature 的。
https://github.com/salvo-rs/salvo/blob/main/examples/static-dir-list/Cargo.toml
salvo = { workspace = true, features=["serve-static"] }