diff --git a/spring-5-webflux-2/src/main/java/com/baeldung/webflux/exceptionhandeling/service/UserService.java b/spring-5-webflux-2/src/main/java/com/baeldung/webflux/exceptionhandeling/service/UserService.java index eafaf421b9..da5a672183 100644 --- a/spring-5-webflux-2/src/main/java/com/baeldung/webflux/exceptionhandeling/service/UserService.java +++ b/spring-5-webflux-2/src/main/java/com/baeldung/webflux/exceptionhandeling/service/UserService.java @@ -19,16 +19,14 @@ public class UserService { this.userRepository = userRepository; } - @GetMapping("/user/{id}") - public Mono getUserByIdThrowingException(@PathVariable String id) { + public Mono getUserByIdThrowingException(String id) { User user = userRepository.findById(id); if (user == null) throw new NotFoundException("User Not Found"); return Mono.justOrEmpty(user); } - @GetMapping("/user/{id}") - public Mono getUserByIdUsingMonoError(@PathVariable String id) { + public Mono getUserByIdUsingMonoError(String id) { User user = userRepository.findById(id); return (user != null) ? Mono.justOrEmpty(user) : Mono.error(new NotFoundException("User Not Found"));