blob: 93499c536aa95b0e2b6a0ad520b50a8797be9840 (
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
36
37
38
39
40
41
42
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.config.server.http;
import com.yahoo.container.jdisc.HttpResponse;
import com.yahoo.vespa.config.protocol.CompressionType;
import com.yahoo.vespa.config.protocol.ConfigResponse;
import java.io.IOException;
import java.io.OutputStream;
import static com.yahoo.jdisc.http.HttpResponse.Status.OK;
/**
* HTTP getConfig response
*
* @author Ulf Lilleengen
*/
public class HttpConfigResponse extends HttpResponse {
public static final String JSON_CONTENT_TYPE = "application/json";
private final ConfigResponse config;
private HttpConfigResponse(ConfigResponse config) {
super(OK);
this.config = config;
}
public static HttpConfigResponse createFromConfig(ConfigResponse config) {
return new HttpConfigResponse(config);
}
@Override
public void render(OutputStream outputStream) throws IOException {
config.serialize(outputStream, CompressionType.UNCOMPRESSED);
}
@Override
public String getContentType() {
return JSON_CONTENT_TYPE;
}
}
|