All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.yahoo.vespa.config.server.http.HttpConfigResponse Maven / Gradle / Ivy

There is a newer version: 8.441.21
Show newest version
// 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;
    }
    
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy