Skip to content

Commit e46484d

Browse files
authored
FooController refactor (eugenp#1345)
1 parent 3de9a69 commit e46484d

1 file changed

Lines changed: 4 additions & 12 deletions

File tree

‎spring-boot/src/main/java/org/baeldung/boot/service/FooController.java‎

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
import org.baeldung.boot.components.FooService;
44
import org.baeldung.boot.model.Foo;
55
import org.springframework.beans.factory.annotation.Autowired;
6-
import org.springframework.http.HttpStatus;
7-
import org.springframework.http.ResponseEntity;
86
import org.springframework.web.bind.annotation.GetMapping;
97
import org.springframework.web.bind.annotation.PathVariable;
108
import org.springframework.web.bind.annotation.RequestParam;
@@ -17,18 +15,12 @@ public class FooController {
1715
private FooService fooService;
1816

1917
@GetMapping("/{id}")
20-
public ResponseEntity<?> getFooWithId(@PathVariable Integer id) throws Exception {
21-
22-
Foo foo = fooService.getFooWithId(id);
23-
24-
return new ResponseEntity<>(foo, HttpStatus.OK);
18+
public Foo getFooWithId(@PathVariable Integer id) throws Exception {
19+
return fooService.getFooWithId(id);
2520
}
2621

2722
@GetMapping("/")
28-
public ResponseEntity<?> getFooWithName(@RequestParam String name) throws Exception {
29-
30-
Foo foo = fooService.getFooWithName(name);
31-
32-
return new ResponseEntity<>(foo, HttpStatus.OK);
23+
public Foo getFooWithName(@RequestParam String name) throws Exception {
24+
return fooService.getFooWithName(name);
3325
}
3426
}

0 commit comments

Comments
 (0)