-
Hello, i'm using actix-web 4.4 and actix-files 0.6.2. I want to serve my static files and use in html files and i also don't want them to be able to seen on mount path. Here is my server code: .service(Files::new("/other", "files/other/").show_files_listing())
.service(Files::new("/sample-files", "files/sample-files/").show_files_listing())
.service(Files::new("/template-files", "files/template-files/").show_files_listing()) when i put that middlewares on my server everyone can see my static files on "/other", "/sample-files", "/template-files" routes on browser. I don't want my static files could be seen on that routes. When i use |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Hey! I added an example to the repo to demonstrate how you might do this: https://github.com/actix/actix-web/blob/master/actix-files/examples/guarded-listing.rs The trick is in this setup, which is a bit of duplication but it's certainly the cleanest way: .service(
Files::new("/assets", EXAMPLES_DIR)
.show_files_listing()
.guard(guard::Header("show-listing", "?1")),
)
.service(Files::new("/assets", EXAMPLES_DIR)) (Sorry for the delay.) |
Beta Was this translation helpful? Give feedback.
-
Thanks, it worked. When you don't answered yet i used a work around for kind of achieving this: basically i gave the first parameter of the |
Beta Was this translation helpful? Give feedback.
Hey! I added an example to the repo to demonstrate how you might do this: https://github.com/actix/actix-web/blob/master/actix-files/examples/guarded-listing.rs
The trick is in this setup, which is a bit of duplication but it's certainly the cleanest way:
(Sorry for the delay.)