You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+41-12Lines changed: 41 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,7 +24,7 @@ axum = "0.8"
24
24
25
25
## Usage
26
26
27
-
### Embedding Static Assets
27
+
### Embedding a directory of static assets
28
28
29
29
Use the `embed_assets!` macro to create a `static_router()` function in scope which will include your static files, embedding them into your binary:
30
30
@@ -41,37 +41,66 @@ This will:
41
41
- Compress them using `gzip` and `zstd` (if beneficial)
42
42
- Generate a `static_router()` function to serve these assets
43
43
44
-
### Conditional Requests & Caching
45
-
46
-
The crate automatically handles:
47
-
48
-
-`Accept-Encoding` header to serve compressed versions if available
49
-
-`If-None-Match` header for ETag validation, returning `304 Not Modified` if unchanged
50
-
51
-
### Required parameter
44
+
#### Required parameter
52
45
53
46
-`path_to_dir` - a valid `&str` string literal of the path to the static files to be included
54
47
55
-
### Optional parameters
48
+
####Optional parameters
56
49
57
50
-`compress = false` - compress static files with zstd and gzip, true or false (defaults to false)
58
51
59
52
-`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)
60
53
61
54
-`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)
62
55
63
-
## Example
56
+
### Embedding a single static asset file
57
+
58
+
Use the `embed_asset!` macro to return a function you can use as a GET handler, which will include your static file, embedded into your binary:
0 commit comments