use of com.z.gateway.common.OpenApiHttpRequestBean in project gateway-dubbox by zhuzhong.
the class OpenApiExceptionHandler method resolveException.
@Override
public ModelAndView resolveException(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) {
OpenApiHttpRequestBean reqBean = (OpenApiHttpRequestBean) request.getAttribute(CommonCodeConstants.REQ_BEAN_KEY);
reqBean.setPrintStr(JSON.toJSONString(ex));
OpenApiResponseUtils.writeRsp(response, reqBean);
return null;
}
use of com.z.gateway.common.OpenApiHttpRequestBean in project gateway-dubbox by zhuzhong.
the class OpenApiAcceptHandlerImpl method acceptRequest.
@Override
public void acceptRequest(HttpServletRequest request, HttpServletResponse response) {
OpenApiHttpRequestBean reqBean = (OpenApiHttpRequestBean) request.getAttribute(CommonCodeConstants.REQ_BEAN_KEY);
String traceId = idService.genInnerRequestId();
reqBean.setTraceId(traceId);
// 重新设置bean
request.setAttribute(CommonCodeConstants.REQ_BEAN_KEY, reqBean);
if (logger.isInfoEnabled()) {
logger.info(String.format("requestId=%s request begin,reqeust=%s", traceId, JSON.toJSONString(reqBean)));
}
// 将当前请求放入线程池处理,若超过线程池最大处理数则抛出reach queue max deepth 异常
addTask2Pool(response, new OpenApiHttpSessionBean(reqBean));
}
use of com.z.gateway.common.OpenApiHttpRequestBean in project gateway-dubbox by zhuzhong.
the class AbstractOpenApiValidateInterceptor method preHandle.
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object obj) throws Exception {
String requestMethod = request.getMethod();
if (!requestMethod.equals(CommonCodeConstants.REQUEST_METHOD.GET.name()) && !requestMethod.equals(CommonCodeConstants.REQUEST_METHOD.POST.name())) {
throw new RuntimeException("请求方法不对,请求方法必须是 GET 或POST");
}
// 初始化请求bean
OpenApiHttpRequestBean reqBean = iniOpenApiHttpRequestBean(request);
request.setAttribute(CommonCodeConstants.REQ_BEAN_KEY, reqBean);
return true;
}
Aggregations