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