spring-cloud / spring-cloud-gateway

An API Gateway built on Spring Framework and Spring Boot providing routing and more.
http://cloud.spring.io
Apache License 2.0
4.54k stars 3.33k forks source link

How to add IgnorePatterns in spring cloud as zuul? #1243

Closed xiaoshao closed 5 years ago

xiaoshao commented 5 years ago

I found that how to ignore the service in issue 185. But I still want to know spring cloud gateway support IgnorePatterns or not? currently, I created a prefilter with implements WebFilter for every request. But I dont think it a good idea.

Do you have more suggestion about it?

ryanjbaxter commented 5 years ago

Seems like that was answered here https://github.com/spring-cloud/spring-cloud-gateway/issues/185#issuecomment-520678570

I am not sure what else to say

xiaoshao commented 5 years ago

@ryanjbaxter I realized that the spring-cloud-gateway add the route definition explicitly, and not generate route definition automatically as zuul after I read the issue 185 again.

thanks @ryanjbaxter

spencergibb commented 5 years ago

It certainly can generate route definitions automatically

xiaoshao commented 5 years ago

@ryanjbaxter @spencergibb I totally missed your means. And @spencergibb missed my mind.

In the issue 185 , @spencergibb told me that, it don't need ignore service not do not need ignore pattern.

about reply from @ryanjbaxter

The gateway isnt proactive like Zuul is and automatically creates routes based on service discovery they have to be explicitly configured (as far as I know). Can you provide an example of where this would be necessary?

I missed the is and in The gateway isnt proactive like Zuul is and automatically creates routes based on service discovery they have to be explicitly configured (as far as I know) .

I think it should be and is.

Now I am still confused that why ignore pattern is not necessary for spring cloud gateway ?

I add spring actuator in the service, but these rest interface should not be available from gateway.

ryanjbaxter commented 5 years ago

You can exclude services from being added as described here https://github.com/spring-cloud/spring-cloud-gateway/issues/185#issuecomment-383782342

xiaoshao commented 5 years ago

@ryanjbaxter I know how to exclude services. My question is how to exclude some rest interface.

Take an example, In the service A, there is some rest interface for bussiness and some rest interface for management. I just want to expose the bussiness interface but not expose management interface with gateway.

How to implement that in spring cloud gateway?

tony-clarke-amdocs commented 5 years ago

I am not following. You control the predicate that will match the requests...so you just define the predicate in such a way so that the managmenent interface will not match any predicate.

xiaoshao commented 5 years ago

@tony-clarke-amdocs I know your mind. But the bussiness rest interface is complex (because of a bad design). It is hard to clear all the bussiness rest interface. And the management interface is clear.