File tree Expand file tree Collapse file tree 1 file changed +20
-1
lines changed
website/content/middleware Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -30,7 +30,20 @@ e.Use(middleware.StaticWithConfig(middleware.StaticConfig{
30
30
}))
31
31
```
32
32
33
- This serves static files from ` static ` directory and enables directory browsing.
33
+ This serves static files from ` static ` directory and enables directory browsing.
34
+
35
+ Default behavior when using with non root URL paths is to append the URL path to the filesystem path.
36
+
37
+ Example:
38
+
39
+ ``` go
40
+ group := root.Group (" somepath" )
41
+ group.Use (middleware.Static (filepath.Join (" filesystempath" )))
42
+ // When an incoming request comes for `/somepath` the actual filesystem request goes to `filesystempath/somepath` instead of only `filesystempath`.
43
+ ```
44
+
45
+ To turn off this behavior set the ` IgnoreBase ` config param to ` true ` .
46
+
34
47
35
48
## Configuration
36
49
@@ -55,6 +68,12 @@ StaticConfig struct {
55
68
// Enable directory browsing.
56
69
// Optional. Default value false.
57
70
Browse bool ` json:"browse"`
71
+
72
+ // Enable ignoring of the base of the URL path.
73
+ // Example: when assigning a static middleware to a non root path group,
74
+ // the filesystem path is not doubled
75
+ // Optional. Default value false.
76
+ IgnoreBase bool ` yaml:"ignoreBase"`
58
77
}
59
78
```
60
79
You can’t perform that action at this time.
0 commit comments