In a Spring controller I want an updateuser
endpoint, a deleteuser
endpoint and a generic one that captures the rest of options:
@PostMapping(value = "/{action:^((?!(updateuser|deleteuser)).)+}")
// Do something depending on `action`, need to capture the match
@PostMapping(value = "/updateuser")
// Update user
@PostMapping(value = "/deleteuser")
// Delete user
Using that regexp throws:
The number of capturing groups in the pattern segment (^((?!updateuser|deleteuser).)*) does not match the number of URI template variables it defines, which can occur if capturing groups are used in a URI template regex. Use non-capturing groups instead.
I have no problem if I use @PostMapping(value = "/{action:^.*(?!updateuser)}")
Which would be the correct regexp?