I want to build a library that will save the Json content of request and response on annotated Spring controller.
So i've build my own annotation @Foo and put it on some controllers:
@Foo
@RequestMapping(method = RequestMethod.POST, value = "/doSomeThing", produces = {
MediaType.APPLICATION_JSON_VALUE, MediaType.TEXT_XML_VALUE,
MediaType.APPLICATION_XML_VALUE})
public ResponseEntity<T> doSomething(/*some parameters*/) {
T t = doSomeJob(T.class);
return new ResponseEntity<T>(t, HttpStatus.OK);
}
I have no guarantee that request and response are in Contrellor's parameters! And i'm catching the call on any Controller having that annotation within an @AfterReturning AOP pointcut.
@Component
@Aspect
public class XYInterceptor
@AfterReturning(
pointcut = "execution(@my.annotation.Foo)")
public void doSomethingWithJsonContent(JoinPoint joinPoint) throws Throwable {
//How can i get json value of request and response here?
}
How can I get request and response content formatted in json (such as it is send/returned to the client) ?
Thanx for your help!