Skip to content

Instantly share code, notes, and snippets.

@josephmtinangi
Created March 4, 2018 13:54
Show Gist options
  • Save josephmtinangi/2b58ae298d77711adf911bc41b4f4634 to your computer and use it in GitHub Desktop.
Save josephmtinangi/2b58ae298d77711adf911bc41b4f4634 to your computer and use it in GitHub Desktop.
Java Create Response Helper Utility Function
public class Helper {
public static ResponseEntity<?> createResponse(boolean success, Object data, String message, HttpStatus code) {
HashMap<String, Object> response = new HashMap<>();
response.put("success", success);
response.put("data", data);
response.put("message", message);
response.put("code", code);
return new ResponseEntity<>(response, code);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment