Home > Back-end >  Java Sprint endpoint matcher using ** not working as expected
Java Sprint endpoint matcher using ** not working as expected

Time:01-27

I am working on an example project to understand better endpoint matchers::

@GetMapping(path ="/v3**", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<byte[]> genericV3GetRequestProxy(ProxyExchange<byte[]> proxy);

But when I send this http call it is not matching:

http://localhost:9000/api/v3asdasd/asd

Instead if I send this one it works:

http://localhost:9000/api/v3asdasd

In the end the correct solution is just:

@GetMapping(path ="/v3/**", produces = MediaType.APPLICATION_JSON_VALUE)

But I wanted to understand why it behaves like I showed.

CodePudding user response:

When you added a slash to your URI you created a separate path segment, as / is defined as the path separator per RFC 3986.

https://www.rfc-editor.org/rfc/rfc3986#section-3.3

  • Related