-
-
Notifications
You must be signed in to change notification settings - Fork 202
Closed
Description
There is a typical use-case for get/find/fetch API like below
get("/users/{userId}", ctx -> {
var userId = ctx.path("userId").value();
return userRepository.findUserById(userId); // can return null, and this is OK for repo
}where null can be returned from a route handler, some time ago the encoder was simply failing on this. Right now it returns just null as text. But it is still not a legal JSON response. The desired behavior is, typically, to return a 404 response in this case.
It is a bit boilerplate to add a null check in every handler like above, so, what I usually do in this situation, is just add a dead simple after() handler that does the null-check and throws 404.
Would it be OK if I add a similar after handler to the project?