Skip to content

Commit c505c6b

Browse files
structwafelpaolobarbolini
authored andcommitted
docs: add explanation of ignore_files to readme
1 parent 0fc2a71 commit c505c6b

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ Use the `embed_assets!` macro to create a `static_router()` function in scope wh
3131
```rust
3232
use static_serve::embed_assets;
3333

34-
embed_assets!("assets", compress = true, cache_busted_paths = ["immutable"]);
34+
embed_assets!("assets", compress = true, ignore_files = ["temp.txt"], cache_busted_paths = ["immutable"]);
3535
let router = static_router();
3636
```
3737

3838
This will:
3939

40-
- Include all files from the `assets` directory
40+
- Include all files from the `assets` directory except `temp.txt`
4141
- Compress them using `gzip` and `zstd` (if beneficial)
4242
- For only files in `assets/immutable`, add a `Cache-Control` header with `public, max-age=31536000, immutable` (since these are marked as cache-busted paths)
4343
- Generate a `static_router()` function to serve these assets
@@ -52,6 +52,8 @@ This will:
5252

5353
- `ignore_dirs = ["my_ignore_dir", "other_ignore_dir"]` - a bracketed list of `&str`s of the paths/subdirectories inside the target directory, which should be ignored and not included. (If this parameter is missing, no subdirectories will be ignored)
5454

55+
- `ignore_files = ["my_ignore_file.txt", "other_ignore_file.js"]` - a bracketed list of `&str`s of the specific files inside the target directory, which should be ignored and not included. (If this parameter is missing, no files will be ignored)
56+
5557
- `strip_html_ext = false` - strips the `.html` or `.htm` from all HTML files included. If the filename is `index.html` or `index.htm`, the `index` part will also be removed, leaving just the root (defaults to false)
5658

5759
- `cache_busted_paths = ["my_immutables_dir", "my_immutable_file"]` - a bracketed list of `&str`s of the subdirectories and/or single files which should gain the `Cache-Control` header with `public, max-age=31536000, immutable` for cache-busted paths. If this parameter is missing, the default is that no embedded files will have the `Cache-Control` header. Note: the files in `cache_busted_paths` need to already be compatible with cache-busting by having hashes in their file paths (for example). All `static-serve` does is set the appropriate header.

0 commit comments

Comments
 (0)