aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ufund-api/src/main/java/com/ufund/api/ufundapi/controller/CupboardController.java15
1 files changed, 13 insertions, 2 deletions
diff --git a/ufund-api/src/main/java/com/ufund/api/ufundapi/controller/CupboardController.java b/ufund-api/src/main/java/com/ufund/api/ufundapi/controller/CupboardController.java
index 106b2e0..d6b71fd 100644
--- a/ufund-api/src/main/java/com/ufund/api/ufundapi/controller/CupboardController.java
+++ b/ufund-api/src/main/java/com/ufund/api/ufundapi/controller/CupboardController.java
@@ -20,9 +20,20 @@ public class CupboardController {
private ArrayList<Need> needs;
private Cupboard cupboard;
+ /**
+ * Creates a Need with the provided object
+ *
+ * @param need The need to create
+ * @return OK response and the need if it was successful, INTERNAL_SERVER_ERROR otherwise
+ */
@PostMapping("")
- public void createNeed(@RequestBody Need need) {
- cupboard.createNeed(need);
+ public ResponseEntity<Need> createNeed(@RequestBody Need need) {
+ try {
+ cupboard.createNeed(need);
+ return new ResponseEntity<>(need, HttpStatus.OK);
+ } catch (IOException ex) {
+ return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
+ }
}
@GetMapping("")