Skip to content

Instantly share code, notes, and snippets.

@skrauchenia
Created July 25, 2013 13:10
Show Gist options
  • Save skrauchenia/6079458 to your computer and use it in GitHub Desktop.
Save skrauchenia/6079458 to your computer and use it in GitHub Desktop.
// your version
@RequestMapping(value="/addNewTag", method=RequestMethod.POST, produces = "application/json")
@ResponseBody
public Map<String, Integer> addNewTag(@RequestBody Map<String, String> requestMap, HttpServletResponse response) throws IOException {
if (addTagOnRuntime(requestMap.get("tagName"))) {
return Collections.singletonMap("statusCode", HttpServletResponse.SC_OK);
} else {
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
return null;
}
}
private boolean addTagOnRuntime(String tagName) {
tagsAddedOnRuntime.add(tagName);
return true;
}
// my version
@RequestMapping(value="/addNewTag", method=RequestMethod.POST, produces = "application/json")
@ResponseBody
public void addNewTag(@RequestBody String newTag) throws IOException {
tagsAddedOnRuntime.add(newTag);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment