Open effleurager opened 1 week ago
Due to how matchers are provisioned (once at config load time, not on every request), they need to have static values as input (except for placeholders). I'm not sure it would be possible to implement this. From a type system standpoint I don't see how the MatchFile struct could take a dynamic try_files input fed by CEL.
In your case, can't you just list out all 10 permutations you want to try? That should work, no? The config is verbose yes, but it should work.
While testing, I discovered a bug with the try_policy
value not being assigned:
https://github.com/caddyserver/caddy/blob/48ce47f1d44da485fbbf6be536a0e3822763f313/modules/caddyhttp/fileserver/matcher.go#L192-L195
I'm preparing a PR, but I'm wondering if I should add a test for CELLibrary
specifically or just add an addition to expressionTests
?
https://github.com/caddyserver/caddy/blob/48ce47f1d44da485fbbf6be536a0e3822763f313/modules/caddyhttp/fileserver/matcher_test.go#L283-L292
Oops! Nice spotting. Yeah any kind of tests you can add are appreciated 😅
Looking at the documentation for the file matcher, the example CEL expression uses an array of strings to specify a list of files to search for. Seeming like the only alternative to globbing for Windows users, I was surprised to find building a list failed to compile with the following error:
As a toy example, this seems like it should be a valid Caddyfile:
Given the severe restriction of globbing being unavailable, this seems like an important fallback to have?