Currently a request method receives a encoded token as parameter (this token is a String
but not JSON or anything like that).
This token then gets decoded to a data class.
@GetMapping(value = "/api/xyz")
public ResponseEntity<XYZ> xyz(@NotBlank String token) {
Data data = Token.parse(token);
...
}
Is it possible to write a annotation similar to how @RequestBody
works that converts a parameter into something else?
The request should just look like that instead:
@GetMapping(value = "/api/xyz")
public ResponseEntity<XYZ> xyz(@TokenParser Data data) {
...
}
This class / annotation should contain the code necessary to convert the token
(String
) to my data class.
The request method should just have the converted data class as parameter.