Category Archives: Programming

Writing REST APIs – CREATE/POST – Best Practices – Part II

Writing REST APIs – CREATE/POST – Best Practices – Part II

This is my second post on Writing REST APIs. Today the focus is on POST HTTP method. Basically POST method is used for create a resource. Sample Request : POST /users { “users” : [{ “firstName” : “Tom”, “lastName” : “Cruise” },{ “firstName” : “Tom”, “lastName” : “Hardy” }] } Sample Response : { “statusCode” :… Read More »

Writing REST APIs – CRUD – Request & Response – Best Practices – Part I

Writing REST APIs - CRUD - Request & Response - Part I

Writing REST APIs – CRUD – Request & Response – Best Practices – Part I

Writing REST APIs - CRUD - Request & Response - Part I

I am going to publish a series of posts  related to REST APIs standards and today we will see some details on designing the request and response for an API. So now we will assume we are going to write an API for user managements and we call this User API. When writing an API, the following… Read More »

Java – Break Filter Chain and Return Custom POJO Response from Servlet Filter

Java - Break Filter Chain and Return Custom POJO Response from Servlet Filter

Java – Break Filter Chain and Return Custom POJO Response from Servlet Filter

Java - Break Filter Chain and Return Custom POJO Response from Servlet Filter

Sample Servlet Filter : package com.application.test.security; import com.application.test.response.ErrorResponse; import com.fasterxml.jackson.databind.ObjectMapper; import javax.servlet.*; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; public class TestFilter implements Filter { @Override public void init(FilterConfig filterConfig) throws ServletException { } @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException,ServletException { if(ANY CONDITION){ //ANY POJO CLASS ErrorResponse errorResponse = new ErrorResponse();… Read More »