how to return only HTTP Status code, if we hit one pre-defined endpoint

613 Views Asked by At

When I hit

@FeignClient(name = "abc_abc", url = "${abc.host}")
public interface validateClient {

    @PostMapping(path = "/api/abc/validate",
            consumes = "application/json",
            produces = "application/json")
    **public <?>  validateResponse**(@RequestHeader HttpHeaders htppHeaders, @RequestParam Map<String, Object> params,
                                                 @RequestBody String request);
}

in this example API: /api/abc/validate i just want to return only HTTP status code what is the return type of validateResponse method ? please some one plz suggest

1

There are 1 best solutions below

2
pan-leszeczek On

Try use ResponseEntity without any "body", here an example.

@PostMapping(path = "/api/abc/validate",
        consumes = "application/json",
        produces = "application/json")
public ResponseEntity validateResponse(@RequestHeader HttpHeaders htppHeaders, @RequestParam Map<String, Object> params,
                                             @RequestBody String request) {
  return ResponseEntity.status(HttpStatus.FOUND).build();
}

You can choose from standard HttpStatus enum, or simply insert an integer for your custom needs