Open yawkat opened 2 months ago
That class is replaced by UriTemplateMatcher
That class is replaced by
UriTemplateMatcher
I did not get this memo 😀 . Now that you mention it @dstepanov, I believe this intention should be properly documented (a mention in the Guide and the UriTemplate
class marked as @Deprecated
)
Well, the class UriTemplateMatcher
suffers from the same ailment as UriTemplate
does.
Just run this test to see for yourself:
package io.micronaut.http.uri;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;
import java.util.Map;
import static org.junit.jupiter.api.Assertions.assertEquals;
class UriTemplateMatcherTest {
@ParameterizedTest
@CsvSource(delimiter = '|', value = {
"{+id*}|one=alpha,two=bravo",
"{#id*}|#one=alpha,two=bravo",
"{#id*}|#one=alpha,two=bravo",
"{;id*}|;one=alpha;two=bravo",
"{&id*}|&one=alpha&two=bravo",
})
void testDeepObjectParam(String template, String expected) {
UriTemplateMatcher templateMatcher = new UriTemplateMatcher(template);
DeepObject deepObject = new DeepObject("alpha", "bravo");
String expansion = templateMatcher.expand(Map.of("id", deepObject));
assertEquals(expected, expansion);
}
}
I didn't deprecate it because it's used in the routes API, and there is no way to use the new one—the idea is to replace one with another in v5. I think that in the future version (maybe even before v5), I would like to have an option for controllers to select what kind of URI style you want: current one based on uri template or simple JAX-RS style.
@dstepanov, @yawkat Are there any plans to fix this bug?
Discussed in https://github.com/micronaut-projects/micronaut-core/discussions/11191