blob: 23b56e94ae49c0bae0377188aeb5772167af0179 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package ai.vespa.metricsproxy.http.yamas;
import ai.vespa.metricsproxy.metric.model.json.JacksonUtil;
import ai.vespa.metricsproxy.metric.model.json.YamasArrayJsonModel;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yahoo.container.jdisc.HttpResponse;
import java.io.IOException;
import java.io.OutputStream;
/**
* @author olaa
*/
public class YamasResponse extends HttpResponse {
private final YamasArrayJsonModel data;
public YamasResponse(int code, YamasArrayJsonModel data) {
super(code);
this.data = data;
}
@Override
public String getContentType() {
return "application/json";
}
@Override
public void render(OutputStream outputStream) throws IOException {
ObjectMapper mapper = JacksonUtil.createObjectMapper();
mapper.writeValue(outputStream, data);
}
}
|