Commit 91cfb54
Add :static_headers setting for custom headers in static file responses (#2089)
This PR implements recent feature request related to static file
responses. It introduces a new configuration setting, `:static_headers`,
which allows developers to define custom headers that will be applied to
all static file responses served by `static!` -method.
Sinatra serves static files directly via `static!`, bypassing filters
and middleware. This makes it so that there is no good ways to add
headers like `Access-Control-Allow-Origin`, which are often needed for
CORS access (e.g., when using fonts or images on canvas).
Co-authored-by: Patrik Ragnarsson <[email protected]>1 parent c918134 commit 91cfb54
3 files changed
+56
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
420 | 420 | | |
421 | 421 | | |
422 | 422 | | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
423 | 432 | | |
424 | 433 | | |
425 | 434 | | |
| |||
2157 | 2166 | | |
2158 | 2167 | | |
2159 | 2168 | | |
| 2169 | + | |
| 2170 | + | |
| 2171 | + | |
| 2172 | + | |
| 2173 | + | |
| 2174 | + | |
| 2175 | + | |
| 2176 | + | |
| 2177 | + | |
| 2178 | + | |
2160 | 2179 | | |
2161 | 2180 | | |
2162 | 2181 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1143 | 1143 | | |
1144 | 1144 | | |
1145 | 1145 | | |
| 1146 | + | |
1146 | 1147 | | |
1147 | 1148 | | |
1148 | 1149 | | |
| |||
1156 | 1157 | | |
1157 | 1158 | | |
1158 | 1159 | | |
| 1160 | + | |
| 1161 | + | |
| 1162 | + | |
1159 | 1163 | | |
1160 | 1164 | | |
1161 | 1165 | | |
| |||
2011 | 2015 | | |
2012 | 2016 | | |
2013 | 2017 | | |
| 2018 | + | |
| 2019 | + | |
2014 | 2020 | | |
2015 | 2021 | | |
2016 | 2022 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
273 | 273 | | |
274 | 274 | | |
275 | 275 | | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
276 | 307 | | |
0 commit comments