FooController refactor
@@ -3,8 +3,6 @@ package org.baeldung.boot.service;
import org.baeldung.boot.components.FooService;
import org.baeldung.boot.model.Foo;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;
@@ -17,18 +15,12 @@ public class FooController {
private FooService fooService;
@GetMapping("/{id}")
- public ResponseEntity<?> getFooWithId(@PathVariable Integer id) throws Exception {
-
- Foo foo = fooService.getFooWithId(id);
-
- return new ResponseEntity<>(foo, HttpStatus.OK);
+ public Foo getFooWithId(@PathVariable Integer id) throws Exception {
+ return fooService.getFooWithId(id);
}
@GetMapping("/")
- public ResponseEntity<?> getFooWithName(@RequestParam String name) throws Exception {
-
- Foo foo = fooService.getFooWithName(name);
-
- return new ResponseEntity<>(foo, HttpStatus.OK);
+ public Foo getFooWithName(@RequestParam String name) throws Exception {
+ return fooService.getFooWithName(name);
}
}
\ No newline at end of file
