title: Optional Request Header in Spring Rest Service
body: <p>I'm using Spring Restful web service &amp; having request body with request header as shown below:</p>
  
  <pre><code>@RequestMapping(value = "/mykey", method = RequestMethod.POST, consumes="applicaton/json")
  public ResponseEntity&lt;String&gt; getData(@RequestBody String body, @RequestHeader("Auth") String authorization)  {
  try {
      ....
  } catch (Exception e) {
      ....
  }
  }
  </code></pre>
  
  <p>I want to pass one more optional request header called "X-MyHeader". How do I specify this optional request header in Spring rest service?</p>
  
  <p>Also, how do I pass this same value in response header??
  Thanks!</p>
  
  <p>UPDATE: I just found that I can set required=false in request header, so one issue is resolved. Now, the only issue remaining is how do I set the header in the response??</p>