Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am in the process of developing a Spring Cloud based API Gateway.
This Gateway acts like a proxy that filters multiple JSON API requests/responses
The gateway has multiple routes that are defined for each JSON API.
I have found a way to define global Request and Response transform filters. But I believe that these global filters will operate
on all routes.
I would like each route to be defined in the, along with a route-specific or local if you may request/response filters.
The route definitions in the would be defined as:
##Spring Cloud API Gateway Properties
### Route 1[0].id=route1[0].uri=[0].predicates[0]=Path=/test1[0].predicates[1]=Method=POST[0].filters[0]=SetPath=/test1[0].filters[1]=RewritePath=/test1, /dest1
### Route 2[1].id=route2[1].uri=[1].predicates[0]=Path=/test2[1].predicates[1]=Method=POST[1].filters[0]=SetPath=/test2[1].filters[1]=RewritePath=/test2, /dest2

What is the best way now to define for each of route1, route2, .... routen, custom route specific request and response transform filters and configuring them for the routes.

What I have tried:

1. Googling
2. Implementing GlobalFilter as
public class RequestTransformationFilter implements GlobalFilter, Ordered { }

This works just fine but is limited to Global filtering of all routes.
Mohibur Rashid 8-Nov-21 1:53am    
What is the difficulties with using @GetMapping or @PostMapping and or @RequestMapping
Mohibur Rashid 8-Nov-21 1:57am    
ohh, you are using Spring, not Spring Boot 2+. may be you can consider this.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900