Closed ramonli closed 4 years ago
Your controller matches /api first, it never hits the gateway
@spencergibb that is exactly what i want, make the request hit gateway first. Is there any means to implement it?
Change the controller mapping to something else and move /api to a gateway route
yes, but if client access the web controller's URL directly, it will bypass gateway. That is some kind of risk, all my filters, something like rate limiter, will be ignored.
Move the controllers out of gateway I guess.
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.
Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.
I'm looking for a way to introduce BFF(backend for frontend) into gateway. Basically my idea is implementing some web controllers in springcloud gateway, and making all requests go through global/customized filters, and then enter my own web controllers(a uri like 'forward:/api/hello/gulu'). For example my routes is defined as below:
and a global filter:
and a customized web controller:
My expectation is that when client requests url 'http://localhost:18006/api/hello/ramon', it shoud intercepted by route 'hello', and then at least filtered by my CustomGlobalFilter, and finally hit HelloController. But the actual result is the request handled by RequestMappingHandlerMapping, just like a simple pure web controller, no any routes or filters triggered.
I am wondering whether it is right to introduce BFF into springcloud gateway, or there is some elegant way to implement this?