Commit 1df4d739 authored by yanghailong's avatar yanghailong

增加debug模式。

parent effd9974
...@@ -6,25 +6,15 @@ import com.iloomo.util.RedisUtil; ...@@ -6,25 +6,15 @@ import com.iloomo.util.RedisUtil;
import com.iloomo.util.Tools; import com.iloomo.util.Tools;
import com.netflix.zuul.ZuulFilter; import com.netflix.zuul.ZuulFilter;
import com.netflix.zuul.context.RequestContext; import com.netflix.zuul.context.RequestContext;
import com.netflix.zuul.http.ServletInputStreamWrapper;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.StreamUtils;
import javax.annotation.Resource;
import javax.servlet.ServletInputStream;
import javax.servlet.http.HttpServletRequestWrapper;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.Charset;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.apache.commons.lang3.StringUtils;
/** /**
* @author * @author
* @version 1.0 * @version 1.0
...@@ -37,6 +27,7 @@ public class PreFilter extends ZuulFilter { ...@@ -37,6 +27,7 @@ public class PreFilter extends ZuulFilter {
private static String KEY = "KLF7KGtS9eZx7DWQ"; private static String KEY = "KLF7KGtS9eZx7DWQ";
private static String IV = "SRl2wsWc9OV3zzch"; private static String IV = "SRl2wsWc9OV3zzch";
@Override @Override
public String filterType() {//拦截类型设置 public String filterType() {//拦截类型设置
return "pre"; //标准拦截 return "pre"; //标准拦截
...@@ -52,6 +43,8 @@ public class PreFilter extends ZuulFilter { ...@@ -52,6 +43,8 @@ public class PreFilter extends ZuulFilter {
return true; return true;
} }
@org.springframework.beans.factory.annotation.Value("${iloomo.debug}")
private String iloomoDebug;
@Override @Override
public Object run() { public Object run() {
...@@ -78,6 +71,7 @@ public class PreFilter extends ZuulFilter { ...@@ -78,6 +71,7 @@ public class PreFilter extends ZuulFilter {
if (requestQueryParams == null) { if (requestQueryParams == null) {
requestQueryParams = new HashMap<String, List<String>>(); requestQueryParams = new HashMap<String, List<String>>();
} }
if ("false".equals(iloomoDebug)) {
if (path.matches(Config.NO_ALL_INTERCEPTOR_PATH)) { if (path.matches(Config.NO_ALL_INTERCEPTOR_PATH)) {
//不需要token和appid //不需要token和appid
} else { } else {
...@@ -101,15 +95,14 @@ public class PreFilter extends ZuulFilter { ...@@ -101,15 +95,14 @@ public class PreFilter extends ZuulFilter {
requestQueryParams.put("business_id", arrayList); requestQueryParams.put("business_id", arrayList);
decode = true; decode = true;
} }
}else if(Tools.notEmpty(token)){ } else if (Tools.notEmpty(token)) {
String userId = RedisUtil.get(token); String userId = RedisUtil.get(token);
if (userId == null) { if (userId == null) {
json.put("msg", "非法token"); json.put("msg", "非法token");
ctx.setResponseBody(json.toString()); ctx.setResponseBody(json.toString());
ctx.setSendZuulResponse(false); ctx.setSendZuulResponse(false);
} }
} } else {
else {
json.put("msg", "非法非法"); json.put("msg", "非法非法");
ctx.setResponseBody(json.toString()); ctx.setResponseBody(json.toString());
ctx.setSendZuulResponse(false); ctx.setSendZuulResponse(false);
...@@ -137,6 +130,7 @@ public class PreFilter extends ZuulFilter { ...@@ -137,6 +130,7 @@ public class PreFilter extends ZuulFilter {
ctx.setRequestQueryParams(requestQueryParams); ctx.setRequestQueryParams(requestQueryParams);
} }
}
ctx.setRequestQueryParams(requestQueryParams); ctx.setRequestQueryParams(requestQueryParams);
return null; return null;
} }
......
...@@ -138,3 +138,5 @@ hystrix: ...@@ -138,3 +138,5 @@ hystrix:
isolation: isolation:
thread: thread:
timeoutInMilliseconds: 10000 timeoutInMilliseconds: 10000
iloomo:
debug: ture
\ No newline at end of file
...@@ -3,7 +3,6 @@ package com.iloomo.util; ...@@ -3,7 +3,6 @@ package com.iloomo.util;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature; import com.alibaba.fastjson.serializer.SerializerFeature;
import com.iloomo.constant.SysConstant; import com.iloomo.constant.SysConstant;
import org.codehaus.jackson.map.util.JSONPObject;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
...@@ -109,19 +108,7 @@ public class AppUtil { ...@@ -109,19 +108,7 @@ public class AppUtil {
return listReturn; return listReturn;
} }
/**
* @param pd
* @param map
* @return
*/
public static Object returnObject(PageData pd, Map map){
if(pd.containsKey("callback")){
String callback = pd.get("callback").toString();
return new JSONPObject(callback, map);
}else{
return map;
}
}
public static String getJson(boolean success,Object msg, PageData pageData){ public static String getJson(boolean success,Object msg, PageData pageData){
Map<String,Object> map = new HashMap<String,Object>(); Map<String,Object> map = new HashMap<String,Object>();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment