FinalProcessHandler.java 735 B

1234567891011121314151617181920
  1. package cn.nosum.gateway.handler;
  2. import cn.nosum.common.dto.ResultInfo;
  3. import cn.nosum.common.http.entity.Context;
  4. import io.netty.channel.ChannelHandlerContext;
  5. import io.netty.channel.SimpleChannelInboundHandler;
  6. public class FinalProcessHandler extends SimpleChannelInboundHandler<Context> {
  7. @Override
  8. protected void channelRead0(ChannelHandlerContext ctx, Context context) throws Exception {
  9. // TODO 这里直接使用了 stat 脚本返回值作为输出,实际处理应该更为复杂
  10. context.getResponse().write(ResultInfo.valueOf(context.getResult()));
  11. }
  12. @Override
  13. public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
  14. ctx.close();
  15. }
  16. }