0

For more complex needs you can create a @Bean of type DiscoveryClientOptionalArgs and inject ClientFilter instances into it, all of which will be applied to the calls from the client to the server.

this description in spring-cloud wiki

@Bean
    public DiscoveryClientOptionalArgs discoveryClientOptionalArgs() {
        DiscoveryClientOptionalArgs discoveryClientOptionalArgs = new DiscoveryClientOptionalArgs();
        discoveryClientOptionalArgs.setAdditionalFilters(Collections.singletonList(new IpCilentFilter()));
        return discoveryClientOptionalArgs;
    }


public class IpCilentFilter extends ClientFilter {
    @Override
    public ClientResponse handle(ClientRequest clientRequest) throws ClientHandlerException {
        // here How to disallow clients to connect
        return getNext().handle(clientRequest);
    }
}

How to disallow clients to connect?

  1. throws ClientHandlerException useless
  2. return null useless

what should I do?

Cœur
  • 37,241
  • 25
  • 195
  • 267

0 Answers0