blob: d82fb6c08e810de6360f91019e83bc6871ecbede (
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
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.container.handler.metrics;
import com.yahoo.container.jdisc.HttpResponse;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.charset.Charset;
/**
* @author gjoranv
*/
public class JsonResponse extends HttpResponse {
private final byte[] data;
public JsonResponse(int code, String data) {
super(code);
this.data = data.getBytes(Charset.forName(DEFAULT_CHARACTER_ENCODING));
}
@Override
public String getContentType() {
return "application/json";
}
@Override
public void render(OutputStream outputStream) throws IOException {
outputStream.write(data);
}
}
|