Created
March 13, 2013 18:25
-
-
Save joshlong/5154769 to your computer and use it in GitHub Desktop.
how to properly send a header and a status code
This file contains hidden or 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 = USER_COLLECTION_URL, method = RequestMethod.POST) | |
| public ResponseEntity<User> registerUser(@RequestParam("username") String username, | |
| @RequestParam("password") String password, | |
| @RequestParam("firstname") String fn, | |
| @RequestParam("lastname") String ln, | |
| @RequestParam("imported") boolean importedFromServiceProvider, | |
| UriComponentsBuilder componentsBuilder) throws Throwable { | |
| User user = this.userService.createOrGet(username, password, fn, ln, importedFromServiceProvider); | |
| UriComponents uriComponents = componentsBuilder.path(USER_COLLECTION_ENTRY_URL).buildAndExpand(user.getId()); | |
| HttpHeaders httpHeaders = new HttpHeaders(); | |
| httpHeaders.setLocation(uriComponents.toUri()); | |
| return new ResponseEntity<User>(user, httpHeaders, HttpStatus.CREATED); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment