Last active
January 11, 2018 22:45
-
-
Save bjpeterdelacruz/ab119548c0c67d8241c6 to your computer and use it in GitHub Desktop.
Multiple Content Types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RequestMapping(value = "pdf", headers = { "Accept=*/*", | |
"content-type=application/json,text/plain" }, method = RequestMethod.POST, produces = "application/pdf") | |
public ResponseEntity<byte[]> getPdf(@RequestBody Object object) { | |
Form form; | |
if (object instanceof Map) { | |
form = new ObjectMapper().convertValue(object, Form.class); | |
} | |
else { | |
try { | |
form = formService.getForm(Long.parseLong(object.toString())); | |
} | |
catch (Exception e) { | |
return new ResponseEntity<>(HttpStatus.UNPROCESSABLE_ENTITY); | |
} | |
} | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment