Saturday, April 22, 2017
Twelve Factor Apps: Spring Cloud Config
I have been using Spring for many years now and I really like the simplicity and non-invasive model of its features. As I have been implementing 12 Factor applications, I needed to start using a central way to configure the many microservices we are building. This is where Spring Cloud Config comes to the rescue.
Wednesday, March 8, 2017
Saturday, March 4, 2017
REST Endpoint returning 404 without Exceptions
At some point in your REST endpoint design, you will need to return a non 200 response. Now, most implementations show how to implement this using exceptions. While this may seem like a nice approach (from a programming language point of view), exceptions can add overhead to the running JVM. This translates to ineffective use of resources of the JVM for supporting non 200 responses.
Here is a gist where you don't use exceptions to return non 200 responses:
A few things to note from this snippet:
Here is a gist where you don't use exceptions to return non 200 responses:
A few things to note from this snippet:
- This is a Spring Boot implementation (Boot makes things so much simple)
- The HttpServletResponse is injected by Boot (Spring MVC), no need of additional setup.
- Notice that the body return is null already, so the non 200 response makes more sense.
Subscribe to:
Posts (Atom)