简体   繁体   中英

How to capture the response of ResponseEntityExceptionHandler to create JWE encrypt

I have springboot based restful web-service. I have CryptoResponseBodyAdvice to capture the response from controller and create JWE out of response body and send JWE as API response. public class CryptoResponseBodyAdvice implements ResponseBodyAdvice

Trouble comes when some exception occurs and request reaches the exception resolver. In such exception scenario the response is not interfered by CryptoResponseBodyAdvice public class ExceptionResolver extends ResponseEntityExceptionHandler

Can you please suggest what kind of ControllerAdvice or something else will help me capture the responses from ResponseEntityExceptionHandler so I can create JWE out of that.

I think you can create a request interceptor which implements ClientHttpRequestInterceptor, in which you will check the statusCode, if statusCode is more than 400, means it's an exception then you can extract it's response in whatever format it is coming and can create JWE out of that.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM