Search in sources :

Example 1 with NettyRoutingFilter

use of org.springframework.cloud.gateway.filter.NettyRoutingFilter in project LinkAgent by shulieTech.

the class GatewayFilterChainFilterInterceptor method beforeFirst.

@Override
public void beforeFirst(Advice advice) {
    final NettyRoutingFilter target = (NettyRoutingFilter) advice.getTarget();
    final Object[] parameterArray = advice.getParameterArray();
    ServerWebExchange exchange = (ServerWebExchange) parameterArray[0];
    final InvokeContext context = exchange.getAttribute(SpringCloudGatewayConstants.GATEWAY_CONTEXT);
    if (context == null || context.isEmpty()) {
        return;
    }
    Pradar.setInvokeContext(context);
    if (!target.getHeadersFilters().contains(requestHttpHeadersFilter)) {
        target.getHeadersFilters().add(requestHttpHeadersFilter);
    }
    if (!target.getHeadersFilters().contains(responseHttpHeadersFilter)) {
        target.getHeadersFilters().add(responseHttpHeadersFilter);
    }
}
Also used : ServerWebExchange(org.springframework.web.server.ServerWebExchange) NettyRoutingFilter(org.springframework.cloud.gateway.filter.NettyRoutingFilter) InvokeContext(com.pamirs.pradar.InvokeContext)

Aggregations

InvokeContext (com.pamirs.pradar.InvokeContext)1 NettyRoutingFilter (org.springframework.cloud.gateway.filter.NettyRoutingFilter)1 ServerWebExchange (org.springframework.web.server.ServerWebExchange)1