use of com.duangframework.core.common.dto.http.response.HttpResponse in project duangframework by tcrct.
the class AbstractAsyncContext method buildExceptionResponse.
protected IResponse buildExceptionResponse(String message) {
HttpResponse httpResponse = new HttpResponse(asyncResponse.getHeaders(), asyncResponse.getCharacterEncoding(), asyncRequest.getContentType());
ReturnDto<String> returnDto = new ReturnDto<>();
returnDto.setData(null);
HeadDto headDto = new HeadDto();
int index = message.indexOf(":");
headDto.setMsg((index > -1) ? message.substring(index + 1, message.length()) : message);
headDto.setRet(1);
headDto.setUri(asyncRequest.getRequestURI());
headDto.setTimestamp(System.currentTimeMillis());
headDto.setRequestId(requestId);
headDto.setClientId(IpUtils.getLocalHostIP());
headDto.setMethod(asyncRequest.getMethod());
returnDto.setHead(headDto);
httpResponse.write(returnDto);
httpResponse.setHeader("status", (headDto.getRet() == 0) ? "200" : "500");
return httpResponse;
}
use of com.duangframework.core.common.dto.http.response.HttpResponse in project duangframework by tcrct.
the class MainProcess method doWork.
@Override
public IResponse doWork(IRequest req, IResponse res) throws Exception {
HttpRequest request = (HttpRequest) req;
HttpResponse response = (HttpResponse) res;
if (ToolsKit.isEmpty(request)) {
throw new EmptyNullException("request is null");
}
if (ToolsKit.isEmpty(response)) {
throw new EmptyNullException("response is null");
}
String target = request.getRequestURI().toString();
AsyncContext asyncContext = new AsyncContextThreadImpl(target, request, response);
return asyncContext.complete();
// AsyncContext asyncContext = new AsyncContextQueueImpl(target, request, response);
// return asyncContext.complete();
}
Aggregations