title: Check if Request is Get, Post, Put or Delete in Exception Handler class
body: <p>I am using java and Spring Boot to create a basic REST API.
  How would I check if a request is any of this {GET, POST, PUT, DELETE}?</p>
  
  <p>This is the method in the exception handler.</p>
  
  <pre><code>@Order(Ordered.HIGHEST_PRECEDENCE)
  @Component
  @ControllerAdvice
  public class ExceptionController extends ResponseEntityExceptionHandler {
  
        @Override
        protectedResponseEntity&lt;Object&gt;handleHttpMessageNotReadable(
        HttpMessageNotReadableException ex,HttpHeaders headers, HttpStatus 
        status, WebRequest request) {
  
         String error = "Not a JSON object";
  
  
         ExceptionResponse response = ExceptionResponse.getBuilder()
                                      .addVerb("POST")
                                      .addURL(Global.URL)
                                      .addMessage(error).build();
         return new ResponseEntity&lt;&gt;(response, HttpStatus.NOT_FOUND);
        }
  
  
  }
  </code></pre>