Quantcast
Channel: Active questions tagged rest - Stack Overflow
Viewing all articles
Browse latest Browse all 3683

How to valid @RequestHeader in spring boot

$
0
0

How can I verify required header if it's missing or wrong format?

    @RequestMapping(value = "/example/{id}", method = RequestMethod.PUT)            public ResponseEntity<> update(@RequestHeader(value="last-modified-date") String lastModDate, HttpServletRequest request,                @RequestBody ReBody rebody, @PathVariable("id") int id) throws Exception{    // Stuff here...    }

the format of "lastModDate" likes "Mon, 28 Aug 2017 02:51:09 GMT"

I would like to do some custom validation on the header attribute i.e.

if (lastModDate == null) {    throw Exception();}

or throw the exception when it's in the wrong format.


Viewing all articles
Browse latest Browse all 3683

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>