Search in sources :

Example 6 with RequestLineFrom

use of com.artipie.http.rq.RequestLineFrom 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

RequestLineFrom (com.artipie.http.rq.RequestLineFrom)6 AsyncResponse (com.artipie.http.async.AsyncResponse)5 Matcher (java.util.regex.Matcher)5 Content (com.artipie.asto.Content)4 Key (com.artipie.asto.Key)4 Response (com.artipie.http.Response)4 Slice (com.artipie.http.Slice)3 KeyFromPath (com.artipie.http.slice.KeyFromPath)3 ByteBuffer (java.nio.ByteBuffer)3 Map (java.util.Map)3 Optional (java.util.Optional)3 Pattern (java.util.regex.Pattern)3 Publisher (org.reactivestreams.Publisher)3 Storage (com.artipie.asto.Storage)2 Digests (com.artipie.asto.ext.Digests)2 PublisherAs (com.artipie.asto.ext.PublisherAs)2 RsStatus (com.artipie.http.rs.RsStatus)2 RsWithStatus (com.artipie.http.rs.RsWithStatus)2 StandardCharsets (java.nio.charset.StandardCharsets)2 Locale (java.util.Locale)2