Search in sources :

Example 6 with ReturnDto

use of com.duangframework.core.common.dto.result.ReturnDto in project duangframework by tcrct.

the class HttpBaseHandler method channelRead0.

@Override
public void channelRead0(final ChannelHandlerContext ctx, final FullHttpRequest request) throws Exception {
    try {
        RequestUtils.verificationRequest(request);
        new ActionHandler(bootStrap, ctx, request).run();
    } catch (VerificationException ve) {
        logger.warn(ve.getMessage());
        ReturnDto<String> returnDto = new ReturnDto<>();
        HeadDto headDto = new HeadDto();
        headDto.setUri(request.uri());
        headDto.setTimestamp(System.currentTimeMillis());
        headDto.setRet(500);
        headDto.setMsg(ve.getMessage());
        returnDto.setData(ve.getMessage());
        returnDto.setHead(headDto);
        ResponseUtils.buildFullHttpResponse(ctx, request, ToolsKit.toJsonString(returnDto));
    }
}
Also used : HeadDto(com.duangframework.core.common.dto.result.HeadDto) VerificationException(com.duangframework.core.exceptions.VerificationException) ReturnDto(com.duangframework.core.common.dto.result.ReturnDto)

Aggregations

HeadDto (com.duangframework.core.common.dto.result.HeadDto)6 ReturnDto (com.duangframework.core.common.dto.result.ReturnDto)6 JSONObject (com.alibaba.fastjson.JSONObject)3 HttpResponse (com.duangframework.core.common.dto.http.response.HttpResponse)1 IEnums (com.duangframework.core.common.enums.IEnums)1 ServiceException (com.duangframework.core.exceptions.ServiceException)1 VerificationException (com.duangframework.core.exceptions.VerificationException)1 JsonRender (com.duangframework.mvc.render.JsonRender)1