use of com.orion.lang.wrapper.HttpWrapper in project orion-ops by lijiahangmax.
the class WrapperResultHandler method handleReturnValue.
@Override
public void handleReturnValue(Object o, MethodParameter methodParameter, ModelAndViewContainer modelAndViewContainer, NativeWebRequest nativeWebRequest) throws Exception {
HttpServletResponse response = nativeWebRequest.getNativeResponse(HttpServletResponse.class);
if (response == null) {
return;
}
HttpWrapper<?> wrapper;
if (o instanceof HttpWrapper) {
wrapper = (HttpWrapper<?>) o;
} else if (o instanceof RpcWrapper) {
wrapper = ((RpcWrapper<?>) o).toHttpWrapper();
} else {
wrapper = new HttpWrapper<>().data(o);
}
modelAndViewContainer.setRequestHandled(true);
response.setContentType(StandardContentType.APPLICATION_JSON);
Servlets.transfer(response, wrapper.toJsonString().getBytes());
}
Aggregations