Open natemcmaster opened 8 years ago
We settled on something like
RewriteOptions.AddRewriteWithPrefix(string prefix, string regex, string replcement)
right?
There was talk of:
RewriteOptions.AddWithPrefix(string prefix, builder =>
{
builder.AddRewrite(regex, replcement);
});
But we shouldn't do anything here without finding a large set of customer rules that would benifit.
Regex is an expensive part of the rewrite middleware a lot in order to do pattern matching. It is common for rewrite patterns to be led by a static prefix.
Example: "blogs/(.*)" => "api/blogs?id=$1"
For this rule, the middleware can avoid unnecessary regex allocations by only running the rule when the path begins with "/blogs/".
Possible API design:
Usage