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

fun.fengwk.convention4j.springboot.starter.webflux.webclient.XHeaderWebClientRequestModifier Maven / Gradle / Ivy

There is a newer version: 1.1.14
Show newest version
package fun.fengwk.convention4j.springboot.starter.webflux.webclient;

import fun.fengwk.convention4j.common.lang.StringUtils;
import fun.fengwk.convention4j.springboot.starter.webflux.context.WebFluxContext;
import fun.fengwk.convention4j.springboot.starter.webflux.tracer.TracerXHeader;
import org.springframework.web.reactive.function.client.ClientRequest;

/**
 * @author fengwk
 */
public class XHeaderWebClientRequestModifier implements WebClientRequestModifier {

    @Override
    public void modify(WebFluxContext webFluxContext, ClientRequest.Builder builder) {
        for (TracerXHeader xHeader : TracerXHeader.values()) {
            String headerName = xHeader.getName();
            String headerValue = webFluxContext.getRequest().getHeaders().getFirst(headerName);
            if (StringUtils.isNotBlank(headerValue)) {
                builder.headers(headers -> headers.set(headerName, headerValue));
            }
        }
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy