I am using Java, Spring and Jersey.
I have a REST API A which receives a query parameter called q
and sends this to another API B to get a response.
I need to implement a change where I first need to pass the query from the client to another API C and use the response from API C to create a new request, i.e. basically wrap the request in an HttpServletRequestWrapper
which has the new q
parameter.
Hopefully this image will clarify this a bit:
So the idea is to use a javax.servlet.Filter
for this scenario. Few questions that bug me:
Is it good practice to call another API from a
Filter
?I am using Spring. Would it be an issue to use
@Autowired
for the client of API C within myFilter
?