title: How do I add headers to a response from spark, when using a transformer
body: <p>I have this:</p>
  
  <pre><code>get ("/test", (req, resp) -&gt; {
      return repository.getAll();
  }, new JsonTransformer());
  </code></pre>
  
  <p>My transformer looks like:</p>
  
  <pre><code>public class JsonTransformer implements ResponseTransformer {
  
      ObjectMapper om = new ObjectMapper();
  
      public JsonTransformer() {
      }
  
      @Override
      public String render(Object o) throws Exception {
          return om.writeValueAsString(o);
      }
  }
  </code></pre>
  
  <p>I've tried adding a header using the header funtion on response like so:</p>
  
  <pre><code>get ("/test", (req, resp) -&gt; {
      resp.header("Content-Type", "application/json");
      return repository.getAll();
  }, new JsonTransformer());
  </code></pre>
  
  <p>And I've tried this which I found in the docs:
  I think this sets the accept-type</p>
  
  <pre><code>get ("/test", "application/json", (req, resp) -&gt; {
      return repository.getAll();
  }, new JsonTransformer());
  </code></pre>
  
  <p>But nowhere I'm getting <code>application/json</code> as my <code>Content-Type</code> header</p>