io.github.hpsocket.soa.starter.web.cloud.exception.CloudSentinelBlockExceptionHandler Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hp-soa-starter-web-cloud Show documentation
Show all versions of hp-soa-starter-web-cloud Show documentation
hp-soa: a fully functional, easy-to-use, and highly scalable microservice framework
The newest version!
package io.github.hpsocket.soa.starter.web.cloud.exception;
import org.springframework.http.HttpStatus;
import io.github.hpsocket.soa.framework.core.exception.ServiceException;
import io.github.hpsocket.soa.framework.web.model.Response;
import io.github.hpsocket.soa.framework.web.support.WebServerHelper;
import io.github.hpsocket.soa.starter.sentinel.exception.DefaultSentinelBlockExceptionHandler;
import io.github.hpsocket.soa.starter.web.cloud.support.TracingHelper;
/** Spring Cloud Sentinel 限流处理器 */
public class CloudSentinelBlockExceptionHandler extends DefaultSentinelBlockExceptionHandler
{
@Override
protected Response> createBlockExceptionResponse(ServiceException se)
{
if(WebServerHelper.isEntry())
return super.createBlockExceptionResponse(se);
return TracingHelper.createExceptionResponse(se, HttpStatus.TOO_MANY_REQUESTS);
}
}