Kotlin coroutines real life example

I love Kotlin and it’s concept of coroutines attracts me. But first I didn’t understand two simple things about using coroutines on backend. Coroutines are useless without non-blocking API People usually think: “OK, I put this Spring RestTemplate request within async coroutine and everything becomes non-blocking and efficient!” Alas, coroutines documentation is a bit misleading. […]

Providing error response in RESTful API. Part 3

In the previous article we discussed error response for each specific situation. Now I’ll show you how this could be easily implemented in a Spring web application. Convert Exception to HTTP response We have a web layer where our controllers reside and a service layer where business logic runs. When our service runs into an exceptional […]

Providing error response in RESTful API. Part 2

Last time we talked about how a proper error response should be structured. Now let’s analyze when we should use each of the HTTP status codes. 401 Unauthorized and 403 Forbidden There’s some confusion about these codes because 401 Unauthorized is actually intended for “unauthenticated”, i.e. user cannot log in, error while 403 Forbidden is […]

Providing error response in RESTful API. Part 1

Providing comprehensive error response is an important part of a well-designed REST architecture. It is very annoying to get “500 Internal Server Error” every time something goes wrong being you a frontend developer, public API user or end customer. Never return 500 When your endpoint returns “500 Internal Server Error” it means just that — […]