Skip to content

Instantly share code, notes, and snippets.

@h-hub
Last active August 1, 2021 07:46
Show Gist options
  • Save h-hub/def258ed9b844a0807ae0bab06fa24ac to your computer and use it in GitHub Desktop.
Save h-hub/def258ed9b844a0807ae0bab06fa24ac to your computer and use it in GitHub Desktop.
@PreAuthorize("hasRole('ROLE_ROLE_ADMIN')")
@RequestMapping(value = "/test", method = RequestMethod.GET, produces = { "application/json",
"application/xml" })
@ResponseBody
@ResponseStatus(code = HttpStatus.OK)
public Map<String, String> get() {
String hostname = null;
try {
hostname = InetAddress.getLocalHost()
.getHostAddress();
} catch (UnknownHostException e) {
hostname = "unknown";
}
HashMap<String, String> map = new HashMap<>();
map.put("name", "Response from API");
map.put("host", hostname);
map.put("status", "up");
return map;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment