Modify request/response based on routing (spring boot )

北战南征 提交于 2021-01-28 07:16:04

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!