feat: expand static_exts + make configurable via config.website.static_exts
Added: pdf, json, xml, txt, csv, wasm, m4a, aac, flac, mov, avi, mkv, glb, gltf, obj, zip. Additional extensions can be configured in config.json: website.static_exts: ['.ext1', '.ext2']
This commit is contained in:
parent
0bf82efdd1
commit
8cd821c1eb
@ -206,13 +206,18 @@ class ProcessorResource(StaticResource,Url2File):
|
|||||||
|
|
||||||
async def _handle(self,request:Request) -> StreamResponse:
|
async def _handle(self,request:Request) -> StreamResponse:
|
||||||
# Fast path for static assets: skip auth closures, i18n, url2processor, isHtml
|
# Fast path for static assets: skip auth closures, i18n, url2processor, isHtml
|
||||||
static_exts = ('.js', '.css', '.png', '.jpg', '.jpeg', '.gif', '.ico',
|
config = getConfig()
|
||||||
|
_base = ('.js', '.css', '.png', '.jpg', '.jpeg', '.gif', '.ico',
|
||||||
'.svg', '.woff', '.woff2', '.ttf', '.eot', '.map',
|
'.svg', '.woff', '.woff2', '.ttf', '.eot', '.map',
|
||||||
'.webp', '.bmp', '.mp3', '.mp4', '.webm', '.ogg', '.wav')
|
'.webp', '.bmp', '.mp3', '.mp4', '.webm', '.ogg', '.wav',
|
||||||
|
'.pdf', '.json', '.xml', '.txt', '.csv', '.wasm',
|
||||||
|
'.m4a', '.aac', '.flac', '.mov', '.avi', '.mkv',
|
||||||
|
'.glb', '.gltf', '.obj', '.zip')
|
||||||
|
cfg_exts = getattr(getattr(config, 'website', None), 'static_exts', None) or []
|
||||||
|
static_exts = tuple(list(_base) + list(cfg_exts))
|
||||||
path_lower = request.path.lower()
|
path_lower = request.path.lower()
|
||||||
if any(path_lower.endswith(ext) for ext in static_exts):
|
if any(path_lower.endswith(ext) for ext in static_exts):
|
||||||
# Skip fast path for virtual path prefixes (startswiths in config)
|
# Skip fast path for virtual path prefixes (startswiths in config)
|
||||||
config = getConfig()
|
|
||||||
skip = any(path_lower.startswith(a.leading) for a in (config.website.startswiths or []))
|
skip = any(path_lower.startswith(a.leading) for a in (config.website.startswiths or []))
|
||||||
if not skip:
|
if not skip:
|
||||||
self.parse_request(request)
|
self.parse_request(request)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user