3

I have to validate the header. For instance the incoming request to the spring cloud gateway is

https://spring-test-gateway.com/cloud/gateway/test/

Header: auth-token:1241241244

Requirement: Call two REST API

a) One is to get the User roles based on the auth-token (/validate/userroles)

b) Other is to get the user id from the auth-token(/validate/userid)

if the user has send the proper token then we will forward to the right micro service.

Question is how to call the above 2 REST API. We thought of calling the two micro service in custom filters and tried with RestTemplate. We are not able to achieve it.

Sorry. if the question is basic. Since RestTemplate is not allowed in spring cloud gateway. might be the configuration is wrong. Any insight of this issue might help us to proceed further.

Shankar P
  • 47
  • 5

1 Answers1

2

We have to use the Customized Filter for this. Within the customized filter we can call the above rest service and this can be accomplished.

https://cloud.spring.io/spring-cloud-gateway/multi/multi__developer_guide.html#_writing_custom_gatewayfilter_factories

Shankar P
  • 47
  • 5