Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for regexes in @Filter for HttpServerFilter #5842

Closed
racevedoo opened this issue Jul 22, 2021 · 2 comments · Fixed by #5954
Closed

Support for regexes in @Filter for HttpServerFilter #5842

racevedoo opened this issue Jul 22, 2021 · 2 comments · Fixed by #5954
Assignees
Labels
type: improvement A minor improvement to an existing feature
Milestone

Comments

@racevedoo
Copy link
Contributor

racevedoo commented Jul 22, 2021

Hi all!

When using @Filter annotations with HttpServerFilter, currently the pattern attribute only supports Ant-style patterns. Because of it, we can't use more complicated patterns (using regex, for example). A simple case that regex can support but Ant can't is accepting all paths except one.

This question was raised on gitter (discussed briefly with @jameskleeh), and I suggested that we support something like @Filter(pattern="/mypath", patternStyle=ANT) or @Filter(pattern="/mypath", patternStyle=REGEX), with the default being Ant, to avoid breaking changes.

One thing to note is that using regexes is less performant than using Ant-style patterns. This should be communicated properly to users.

If this is fine, I can come up with a PR.

Expected Behaviour

Micronaut should support more complex patterns for @Filter

Actual Behaviour

Micronaut only supports simple Ant-style patterns for @Filter

@jameskleeh jameskleeh added type: improvement A minor improvement to an existing feature status: under consideration The issue is being considered, but has not been accepted yet labels Jul 22, 2021
@jameskleeh
Copy link
Contributor

@racevedoo Proposal looks good! PR welcome

@jameskleeh jameskleeh removed the status: under consideration The issue is being considered, but has not been accepted yet label Jul 28, 2021
racevedoo added a commit to racevedoo/micronaut-core that referenced this issue Aug 9, 2021
Adds a attribute to the `Filter` annotation, specifying which style of
pattern to use, keeping Ant as the default (avoiding breaking changes).

Fixes micronaut-projects#5842
racevedoo added a commit to racevedoo/micronaut-core that referenced this issue Aug 9, 2021
Adds a attribute to the `Filter` annotation, specifying which style of
pattern to use, keeping Ant as the default (avoiding breaking changes).

Fixes micronaut-projects#5842
racevedoo added a commit to racevedoo/micronaut-core that referenced this issue Aug 9, 2021
Adds a attribute to the `Filter` annotation, specifying which style of
pattern to use, keeping Ant as the default (avoiding breaking changes).

Fixes micronaut-projects#5842
racevedoo added a commit to racevedoo/micronaut-core that referenced this issue Aug 10, 2021
Adds a attribute to the `Filter` annotation, specifying which style of
pattern to use, keeping Ant as the default (avoiding breaking changes).

Fixes micronaut-projects#5842
racevedoo added a commit to racevedoo/micronaut-core that referenced this issue Aug 19, 2021
Adds a attribute to the `Filter` annotation, specifying which style of
pattern to use, keeping Ant as the default (avoiding breaking changes).

Fixes micronaut-projects#5842
racevedoo added a commit to racevedoo/micronaut-core that referenced this issue Aug 19, 2021
Adds a attribute to the `Filter` annotation, specifying which style of
pattern to use, keeping Ant as the default (avoiding breaking changes).

Also adds proper documentation.

Fixes micronaut-projects#5842
jameskleeh pushed a commit that referenced this issue Aug 23, 2021
Adds a attribute to the `Filter` annotation, specifying which style of
pattern to use, keeping Ant as the default (avoiding breaking changes).

Also adds proper documentation.

Fixes #5842
@racevedoo
Copy link
Contributor Author

Merged into 3.1.x

@jameskleeh jameskleeh added this to the 3.1.0 milestone Aug 23, 2021
@jameskleeh jameskleeh linked a pull request Aug 23, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: improvement A minor improvement to an existing feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants