I have an API path GET /users/copy
. I can have two APIs with the same /users/type
path but with different sets of RequestParams using the following construction:
@GetMapping(value = "/users/copy", params = {"type"})
public ResponseEntity<UserDto> copyUserWithType(@RequestParam UserTypeEnum type) {
...
}
@GetMapping(value = "/users/copy", params = {"origin"})
public ResponseEntity<UserDto> copyUserWithOrigin(@RequestParam UserOriginEnum origin) {
...
}
BUT in case I need to have different APIs for different user types (like for type = OLD
and type = NEW
), is there a way to still have the same GET /users/copy
path for them?
Perhaps something like:
@GetMapping(value = "/users/copy", params = {"type=OLD"})
public ResponseEntity<UserDto> copyUserWithTypeOld(@RequestParam UserTypeEnum type) {
...
}
@GetMapping(value = "/users/copy", params = {"type=NEW"})
public ResponseEntity<UserDto> copyUserWithTypeNew(@RequestParam UserTypeEnum type) {
...
}