micronaut-projects / micronaut-core

Micronaut Application Framework
http://micronaut.io
Apache License 2.0
6k stars 1.04k forks source link

Uri template rewrite #10921

Closed dstepanov closed 1 week ago

dstepanov commented 2 weeks ago

This is an attempt to get rid of the old UriTemplate, UriMatchTemplate, and UriTypeMatchTemplate (not used in Core). The implementation of matching/expanding is very confusing and hard to understand, with all the things being changed in the inherited constructor methods, etc. It does not allow adding any changes that we might need.

The new implementation is split into a parser, an expander, and an alternative URI template matcher. The matcher now matches segments of the path, allowing to match without always using the regexp; this should improve the performance of matching basic /hello or /hello/{world}. In the future, we can implement routing, which will combine similar segments into one, reducing the complexity for N to something better, considering most routes share the same prefix.

The new matcher passes previous tests and is now used to match the routes. However, there are still some cases where the old template is used: resolving conflicts and the URI builder. Next, I will investigate what needs to be aligned with the JAX-RS implementation.

Unfortunately, the classes are public and cannot be removed or changed, so we have a new implementation until v5.

sonarcloud[bot] commented 2 weeks ago

Quality Gate Failed Quality Gate failed

Failed conditions
2 New Bugs (required ≤ 0)
1 New Critical Issues (required ≤ 0)
1 New Blocker Issues (required ≤ 0)

See analysis details on SonarCloud

Catch issues before they fail your Quality Gate with our IDE extension SonarLint

dstepanov commented 1 week ago

@graemerocher Pls merge