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
Allow Advanced PathSpec optional behavior in ServletContextHandler addServlet and addFilter #5810
Comments
Two approaches:
I think 2) is the best approach if it matches the requirements. |
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
Late to the party here, but I just want to note that I am not in favour of putting any extended path syntax into web.xml or annotations. |
I agree with this. |
+ Created a common `Mapping` base for `FilterMapping` and `ServletMapping` + `Mapping` contains an array of PathSpec. The `String` based methods assume `ServletPathSpec`. + Convert most handling of string pathSpecs to `PathSpec` instances + Modified `ConstraintMapping` to also use a PathSpec + Modified JSP and annotation handling to cope with any existing non standard path specs + Made ServletHandler update mappings respect the order of the mappings TODO: + Should `ConstraintMapping` extend `Mapping` ? + Convert `ConstraintSecurityHandler` to use `PathMappings` so it can handle non standard PathSpecs + Review remaining calls to `Mapping.getPathSpecs` and `ConstrainMapping.getPathSpec` + Currently Quick Start operates on just the string versions of PathSpec, as it must be able to write a web.xml which can only contain standard path specs. Should it fail when it sees a non standard pathspec, or assume that it will again be programmatically added during quick start? + Review how frequently we are creating new arrays of path spec and/or converting path specs to/from strings. Best resolution for such things are ultility methods on Mapping (eg `#containsPathSpec`) + More tests
+ Converted `ConstraintSecurityHandler` to use `PathMappings` so it can handle non standard PathSpecs
+ Fixed test by reverting ServletMapping normalize
So I have changed the PR so that rather than an extra non-standard I've added some testing, but more is probably needed. Specially for the complex way security constraints are merged. |
@joakime is there still demand for this? |
Closed in favor of the approach in #7748 |
Jetty version
Jetty 9.4.x
Description
Currently the
ServletHandler
uses thePathMappings
feature of Jetty internals.And it (correctly) only adds
ServletPathSpec
in response to the web descriptor or embedded usageof ServletContextHandler.addServlet() or ServletContextHandler.addFilter() usage.
This is a request to add the ability to add servlets or filters based on one of the more advanced PathSpec features
Such as RegexPathSpec or UriTemplatePathSpec.
Ideally supporting :
@WebServlet("regex:/a/[^/]+/b/[^/]+")
or<url-pattern>uri:/a/{foo}/b/{zed}</url-pattern>
The text was updated successfully, but these errors were encountered: