io.github.unickcheng.rhandler.response.ResponseAdvice Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of response-handler-core Show documentation
Show all versions of response-handler-core Show documentation
The core module which supports RESTful API, exception handler, openapi
The newest version!
/*
* create on 2023-01-06
* GitHub https://github.com/UNICKCHENG/Response-Handler
*/
package io.github.unickcheng.rhandler.response;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.github.unickcheng.rhandler.exception.ExceptionHandlerAdvice;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.MethodParameter;
import org.springframework.http.MediaType;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.server.ServerHttpRequest;
import org.springframework.http.server.ServerHttpResponse;
import org.springframework.http.server.ServletServerHttpResponse;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice;
import javax.validation.constraints.NotNull;
import java.util.TimeZone;
/**
* 拦截所有 ResponseBody
* @see #beforeBodyWrite 所有被拦截的 ResponseBody 进行额外处理
* @see #supports 确保哪些情况进行拦截, true 表示拦截, false 表示不拦截, 被拦截则会进入 {@link #beforeBodyWrite 进行处理}
* @see ResponseBodyAdvice 修改 ResponseBody 的拦截器
* @see ExceptionHandlerAdvice 关于异常拦截的封装
* @author unickcheng
*/
//@RestControllerAdvice(annotations = {RHandlerResponseBody.class})
@RestControllerAdvice
@SuppressWarnings("NullableProblems")
public class ResponseAdvice implements ResponseBodyAdvice