cherokee / webserver

Cherokee Web Server
GNU General Public License v2.0
568 stars 104 forks source link

Repetition of reg expressions in redirects #1268

Closed finnianr closed 3 years ago

finnianr commented 3 years ago

I am looking at the official documentation for redirection. In this particular example is shows that you first create a reg expression rule, then assign an internal redirect handler for that rule. But in the handler the exact same regular expression is specified again. This is counter to the DRY principle. Why the need for this repetition?

skinkie commented 3 years ago

@finnianr this is because the match is how you arrive at the handler, and the handler that does the operation are not integrated. The matches only purpose is to get you there, but may also be more generic, you could a directory match with a redirection for example. In addition the handler may have more replacements making it not a 1:1 relationship.