Skip to content

Is there any way to dont see file listing and still see pictures on layout? #3178

Answered by robjtede
Necoo33 asked this question in Q&A
Discussion options

You must be logged in to vote

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.)

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by robjtede
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #3177 on October 29, 2023 23:52.