Skip to content

Commit a79682d

Browse files
author
Peter Vestlin
committed
Refakt.
1 parent 774bcd6 commit a79682d

File tree

1 file changed

+1
-8
lines changed

1 file changed

+1
-8
lines changed

src/main/kotlin/nu/westlin/kartrepo/KartController.kt

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,7 @@ class KartController @Autowired constructor(val kartRepository: KartRepository)
1111

1212
@RequestMapping("/user")
1313
fun greeting(@RequestParam(value = "username", defaultValue = "pwestlin") username: String, response: HttpServletResponse): User {
14-
val user: User? = kartRepository.load(username)
15-
16-
if (user == null) {
17-
throw NotFoundException("User $username not found")
18-
}
19-
20-
return user
21-
14+
return kartRepository.load(username) ?: throw NotFoundException("User $username not found")
2215
}
2316

2417
@RequestMapping("/users")

0 commit comments

Comments
 (0)