I'm new to the Spring Boot filter
I'need to modify the response produced by the servlet(impl) to some pattern.
For example, GetProductImpl will give the response of
{
"id": 72167,
"merchantId": 3,
"amount": 1,
"state": "Unused"
}
So before it gets to send back to client i need to modify it to (it's kind of put the response under module)(for all response by all servlet)
{
"module":[{
"id": 72167,
"merchantId": 3,
"amount": 1,
"state": "Unused"
}],
"success":true,
"errorCode":null,
"notSuccess":false
}
i looking for any method that can let me do this, because it's no point to do it inside the impl because if like that i need to do for all the impl (which is a lot and not viable).
If anyone have any other method that can achieve this also can because i don't know what approach to take to do this(java example also will do).
Thank you.
My current approach of using filter seems to hit the wall because i using addFilter, addFilterBefore or even addFilterAfter, all of them need to have the out filter class which i don know what it is and focus on web security stuff (UsernamePasswordAuthenticationFilter::class.java).
.addFilterBefore(JWTAuthenticationFilter(tokenAuthenticationService, objectMapper), UsernamePasswordAuthenticationFilter::class.java)