title: Spring what is the easiest way to return custom Http status, headers and body to Rest Client
body: <p>I would like to return to my Rest Client the simplest answer.
  Only the:</p>
  
  <ul>
  <li>http status code <strong>201</strong></li>
  <li>http status message <strong>Created</strong></li>
  <li>http header Content <strong>Type</strong></li>
  <li>http response body <strong>Custom string answer</strong></li>
  </ul>
  
  <p>What is the easiest way?</p>
  
  <p>I've used to use <code>ResponseEntity</code> object this way:</p>
  
  <p><code>return new ResponseEntity&lt;String&gt;("Custom string answer", HttpStatus.CREATED);</code>,</p>
  
  <p>but unfortunately, I can not simple pass http header in constructor.</p>
  
  <p>I have to create <code>HttpHeaders</code> object and there add my custom header like this:</p>
  
  <pre><code>MultiValueMap&lt;String, String&gt; headers = new HttpHeaders();
  headers.add(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_PLAIN_VALUE);
  
  return new ResponseEntity&lt;String&gt;("Custom string answer", headers, HttpStatus.CREATED);
  </code></pre>
  
  <p>But I am looking for something simpler. Something that could fit one line of code.</p>
  
  <p>Can Anyone help?</p>