@GetMapping(value = "/mapping-consume", consumes = "application/json")
consumes = "application/json"
이라는 뜻은 요청 헤더의 Content-Type이 json형식이어야 한다는 의미이다. (서버가 소비하는 입장)
@GetMapping(value = "/mapping-consume", headers = "mode=debug")
headers = "mode=debug"
의 뜻은 요청 헤더에 해당 해더 key와 value가 다음과 같아야한다는 의미이다.
@GetMapping(value = "/mapping-consume", produces = "text/html")
produces = "text/html"
의 뜻은 요청 헤더의 Accept-type과 일치해야 한다는 의미이다.(서버가 제공하는 입장)
@GetMapping("/headers")
public String headers(
HttpServletRequest request,
HttpServletResponse response,
HttpMethod httpMethod,
Locale locale,
@RequestHeader MultiValueMap<String,String> headerMap,
@RequestHeader("host") String host,
@CookieValue(value = "myCookie", required = false) String cookie
) {
log.info("request = {}",request);
log.info("response = {}", response);
log.info("httpMethod = {}", httpMethod);
log.info("locale = {}", locale);
log.info("headerMap = {}", headerMap);
log.info("host = {}", host);
log.info("cookie = {}", cookie);
return "ok";
}
host는 요청의 필수값,
Cookie의 경우 required default는 true (없다면 요청이 처리되지 않는다.)