Search in sources :

Example 1 with ContentType

use of com.artipie.http.headers.ContentType in project artipie by artipie.

the class PromuSlice method response.

@Override
public Response response(final String line, final Iterable<Map.Entry<String, String>> headers, final Publisher<ByteBuffer> body) {
    final String ctype = new Accept(headers).values().get(0);
    try (StringWriter writer = new StringWriter()) {
        final MetricsOutput output = new PrometheusOutput(writer, ctype, new HashSet<>(new RqParams(new RequestLineFrom(line).uri()).values("name")));
        this.metrics.publish(output);
        return new RsFull(RsStatus.OK, new Headers.From(new ContentType(ctype)), new Content.From(writer.toString().getBytes(StandardCharsets.UTF_8)));
    } catch (final IOException ioe) {
        throw new ArtipieIOException(ioe);
    }
}
Also used : Accept(com.artipie.http.headers.Accept) ContentType(com.artipie.http.headers.ContentType) ArtipieIOException(com.artipie.asto.ArtipieIOException) IOException(java.io.IOException) ArtipieIOException(com.artipie.asto.ArtipieIOException) RsFull(com.artipie.http.rs.RsFull) StringWriter(java.io.StringWriter) RqParams(com.artipie.http.rq.RqParams) Content(com.artipie.asto.Content) MetricsOutput(com.artipie.metrics.publish.MetricsOutput) RequestLineFrom(com.artipie.http.rq.RequestLineFrom) PrometheusOutput(com.artipie.metrics.publish.PrometheusOutput)

Aggregations

ArtipieIOException (com.artipie.asto.ArtipieIOException)1 Content (com.artipie.asto.Content)1 Accept (com.artipie.http.headers.Accept)1 ContentType (com.artipie.http.headers.ContentType)1 RequestLineFrom (com.artipie.http.rq.RequestLineFrom)1 RqParams (com.artipie.http.rq.RqParams)1 RsFull (com.artipie.http.rs.RsFull)1 MetricsOutput (com.artipie.metrics.publish.MetricsOutput)1 PrometheusOutput (com.artipie.metrics.publish.PrometheusOutput)1 IOException (java.io.IOException)1 StringWriter (java.io.StringWriter)1