actix / actix-web

Actix Web is a powerful, pragmatic, and extremely fast web framework for Rust.
https://actix.rs
Apache License 2.0
21.44k stars 1.66k forks source link

multiple folders as static directories #3402

Open robjtede opened 3 months ago

robjtede commented 3 months ago

Possible API

Files::new("/", ["./dist", "./public"])

Cavets

As noted in the discussion answers, this does make it hard to support options like show_index.

Discussed in https://github.com/actix/actix-web/discussions/3398

Originally posted by **Aobanana-chan** June 10, 2024 For some reasons, I am migrating my website from Node.js/Fastify to Actix Web, but I am having some difficulties setting up static directories. I tried to mount two directories, "./public" and "./dist" to "/", but it failed. Here is a simplified example code: ``` App::new() .service(Files::new("/", "./dist")) .service(Files::new("/", "./public")) ``` In the first service, if the file is not found, it directly responds with a 404 instead of moving to the next service. I realize this approach doesn't work.