问题
Let me try to explain the diagram and problem that I want to solve. The product has multiple services (GET, DELETE, POST, PUT). All products have different payload and header requirement.
e.g - product 1 expects user-id, department-id, and token - in order to make the service work. For post, it might need some payload modification. product 2 expects a simple token with some additional headers and also some payload modifications. product 3 is directly exposed with no modifications.
The actor can access these products only from one API exposed (connect.company.com). The actor gets bearer token from authentication and also gets permission. Once Actor is authenticated and authorized they invoke products. In order to make products pluggable I want to delegate the request and header creation responsibility to product owners. So they implement the adaptor interface and plug it in the system. One thought I had that Adaptor can be a class that I can inject in the framework as a filter (providing get, post, put method for modifications) and these adaptor needs to be invoked only when the respective product is called. product 1 adaptor should not be invoked in product 2 call is made.
Any clue or help on how to design these adaptors will be appreciated.
I am using spring-boot with spring security. ( Note - I saw Netflix zuul it has the capability of routing and also provides filter pre, post, and others but I think they will be invoked irrespective of routing and I want routing based adaptor invocation).
来源:https://stackoverflow.com/questions/64586116/modify-request-response-based-on-routing-spring-boot