Search in sources :

Example 1 with BaseEntity

use of com.artipie.docker.http.BaseEntity in project artipie by artipie.

the class DockerRoutingSlice method response.

@Override
public Response response(final String line, final Iterable<Map.Entry<String, String>> headers, final Publisher<ByteBuffer> body) {
    final RequestLineFrom req = new RequestLineFrom(line);
    final String path = req.uri().getPath();
    final Matcher matcher = PTN_PATH.matcher(path);
    final Response rsp;
    if (matcher.matches()) {
        final String group = matcher.group(1);
        if (group.isEmpty() || group.equals("/")) {
            rsp = new AsyncResponse(this.settings.auth().thenApply(auth -> new BasicAuthSlice(new BaseEntity(), auth, user -> !user.equals(Permissions.ANY_USER)).response(line, headers, body)));
        } else {
            rsp = this.origin.response(new RequestLine(req.method().toString(), new URIBuilder(req.uri()).setPath(group).toString(), req.version()).toString(), new Headers.From(headers, DockerRoutingSlice.HDR_REAL_PATH, path), body);
        }
    } else {
        rsp = this.origin.response(line, headers, body);
    }
    return rsp;
}
Also used : AsyncResponse(com.artipie.http.async.AsyncResponse) BasicAuthSlice(com.artipie.http.auth.BasicAuthSlice) RequestLine(com.artipie.http.rq.RequestLine) Matcher(java.util.regex.Matcher) BaseEntity(com.artipie.docker.http.BaseEntity) RequestLineFrom(com.artipie.http.rq.RequestLineFrom) RequestLineFrom(com.artipie.http.rq.RequestLineFrom) AsyncResponse(com.artipie.http.async.AsyncResponse) URIBuilder(org.apache.http.client.utils.URIBuilder)

Aggregations

BaseEntity (com.artipie.docker.http.BaseEntity)1 AsyncResponse (com.artipie.http.async.AsyncResponse)1 BasicAuthSlice (com.artipie.http.auth.BasicAuthSlice)1 RequestLine (com.artipie.http.rq.RequestLine)1 RequestLineFrom (com.artipie.http.rq.RequestLineFrom)1 Matcher (java.util.regex.Matcher)1 URIBuilder (org.apache.http.client.utils.URIBuilder)1