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

org.zalando.riptide.autoconfigure.FlowHttpRequestInterceptor Maven / Gradle / Ivy

There is a newer version: 4.3.0
Show newest version
package org.zalando.riptide.autoconfigure;

import org.apache.hc.core5.http.EntityDetails;
import org.apache.hc.core5.http.HttpRequest;
import org.apache.hc.core5.http.HttpRequestInterceptor;
import org.apache.hc.core5.http.protocol.HttpContext;
import org.apiguardian.api.API;
import org.zalando.opentracing.flowid.Flow;

import static org.apiguardian.api.API.Status.STABLE;

/**
 * This class is adapted from org.zalando.opentracing.flowid.httpclient.FlowHttpRequestInterceptor.
 * The original class is based on Apache HttpClient 4.x, but we use Apache HttpClient 5.x.
 */
@API(status = STABLE)
public final class FlowHttpRequestInterceptor implements HttpRequestInterceptor {

    private final Flow flow;

    public FlowHttpRequestInterceptor(final Flow flow) {
        this.flow = flow;
    }

    @Override
    public void process(HttpRequest httpRequest, EntityDetails entityDetails, HttpContext httpContext) {
        flow.writeTo(httpRequest::addHeader);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy