|
|
|
@ -5,6 +5,7 @@ import java.io.RandomAccessFile; |
|
|
|
|
import java.net.URI; |
|
|
|
|
import java.nio.charset.Charset; |
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
|
import io.netty.handler.codec.http.*; |
|
|
|
|
import org.fengfei.lanproxy.common.JsonUtil; |
|
|
|
|
|
|
|
|
@ -33,7 +34,7 @@ public class HttpRequestHandler extends SimpleChannelInboundHandler<FullHttpRequ |
|
|
|
|
protected void channelRead0(ChannelHandlerContext ctx, FullHttpRequest request) throws Exception { |
|
|
|
|
|
|
|
|
|
// GET返回页面;POST请求接口
|
|
|
|
|
if (request.getMethod() != HttpMethod.POST) { |
|
|
|
|
if (request.method() != HttpMethod.POST) { |
|
|
|
|
outputPages(ctx, request); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
@ -41,7 +42,7 @@ public class HttpRequestHandler extends SimpleChannelInboundHandler<FullHttpRequ |
|
|
|
|
ResponseInfo responseInfo = ApiRoute.run(request); |
|
|
|
|
|
|
|
|
|
// 错误码规则:除100取整为http状态码
|
|
|
|
|
outputContent(ctx, request, responseInfo.getCode() / 100, JsonUtil.object2json(responseInfo), |
|
|
|
|
outputContent(ctx, request, responseInfo.getCode() / 100, JSONObject.toJSONString(responseInfo), |
|
|
|
|
"Application/json;charset=utf-8"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|