-
Notifications
You must be signed in to change notification settings - Fork 718
Closed
Description
I'm using SpringCloud-LoadBalancer and want to code a loadBalancer which select instance by header "x-area".Here is the code:
public class CustomLoadBalancer extends RoundRobinLoadBalancer{
...
...
@Override
public Mono<Response<ServiceInstance>> choose(Request request){
DefaultRequestContext requestContext = (DefaultRequestContext) request.getContext();
RequestData clientRequest = (RequestData) requestContext.getClientRequest();
HttpHeaders headers = clientRequest.getFirst("x-area");
.....
}
...
...
}
But the requestContext.getClientRequest() cannot cast to RequestData,and here is the debug info:
The LoadBalancerRequestFactory$lambda cannot cast to RequestData,But the arg$2 is what I need,how can I get It? or There is another way which can get header?