Skip to content

Commit

Permalink
Response refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Federico Martín Lara committed Feb 3, 2023
1 parent f2ee1cb commit 067f17e
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public ResponseEntity<Status> status() {
}

@PostMapping("/execute")
public ResponseEntity<?> executeTask(@Valid @RequestBody Task task, BindingResult result) {
public ResponseEntity<Map<String, Object>> executeTask(@Valid @RequestBody Task task, BindingResult result) {
Map<String, Object> response = new HashMap<>();

try {
Expand All @@ -70,16 +70,16 @@ public ResponseEntity<?> executeTask(@Valid @RequestBody Task task, BindingResul
.collect(Collectors.toList());

response.put("errors", errors);
return new ResponseEntity<Map<String, Object>>(response, HttpStatus.BAD_REQUEST);
return new ResponseEntity<>(response, HttpStatus.BAD_REQUEST);
}

log.info("Ejecutar: {}", task.getName());
run(task.getName());
response.put("mensaje", "Tarea ejecutada correctamente");
return new ResponseEntity<Map<String, Object>>(response, HttpStatus.OK);
return new ResponseEntity<>(response, HttpStatus.OK);
} catch (Exception e) {
response.put("error", e.getMessage());
return new ResponseEntity<Map<String, Object>>(response, HttpStatus.INTERNAL_SERVER_ERROR);
return new ResponseEntity<>(response, HttpStatus.INTERNAL_SERVER_ERROR);
}
}

Expand Down

0 comments on commit 067f17e

Please sign in to comment.