Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
S
springCloud
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
os
springCloud
Commits
1df4d739
Commit
1df4d739
authored
Feb 20, 2020
by
yanghailong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加debug模式。
parent
effd9974
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
57 additions
and
74 deletions
+57
-74
PreFilter.java
iloomo-ribbon/src/main/java/com/iloomo/filter/PreFilter.java
+53
-59
application-test.yml
iloomo-ribbon/src/main/resources/application-test.yml
+3
-1
AppUtil.java
iloomo-template/src/main/java/com/iloomo/util/AppUtil.java
+1
-14
No files found.
iloomo-ribbon/src/main/java/com/iloomo/filter/PreFilter.java
View file @
1df4d739
...
...
@@ -6,25 +6,15 @@ import com.iloomo.util.RedisUtil;
import
com.iloomo.util.Tools
;
import
com.netflix.zuul.ZuulFilter
;
import
com.netflix.zuul.context.RequestContext
;
import
com.netflix.zuul.http.ServletInputStreamWrapper
;
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.HttpServletResponse
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.nio.charset.Charset
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
org.apache.commons.lang3.StringUtils
;
/**
* @author
* @version 1.0
...
...
@@ -37,6 +27,7 @@ public class PreFilter extends ZuulFilter {
private
static
String
KEY
=
"KLF7KGtS9eZx7DWQ"
;
private
static
String
IV
=
"SRl2wsWc9OV3zzch"
;
@Override
public
String
filterType
()
{
//拦截类型设置
return
"pre"
;
//标准拦截
...
...
@@ -52,6 +43,8 @@ public class PreFilter extends ZuulFilter {
return
true
;
}
@org
.
springframework
.
beans
.
factory
.
annotation
.
Value
(
"${iloomo.debug}"
)
private
String
iloomoDebug
;
@Override
public
Object
run
()
{
...
...
@@ -78,6 +71,7 @@ public class PreFilter extends ZuulFilter {
if
(
requestQueryParams
==
null
)
{
requestQueryParams
=
new
HashMap
<
String
,
List
<
String
>>();
}
if
(
"false"
.
equals
(
iloomoDebug
))
{
if
(
path
.
matches
(
Config
.
NO_ALL_INTERCEPTOR_PATH
))
{
//不需要token和appid
}
else
{
...
...
@@ -101,15 +95,14 @@ public class PreFilter extends ZuulFilter {
requestQueryParams
.
put
(
"business_id"
,
arrayList
);
decode
=
true
;
}
}
else
if
(
Tools
.
notEmpty
(
token
))
{
}
else
if
(
Tools
.
notEmpty
(
token
))
{
String
userId
=
RedisUtil
.
get
(
token
);
if
(
userId
==
null
)
{
json
.
put
(
"msg"
,
"非法token"
);
ctx
.
setResponseBody
(
json
.
toString
());
ctx
.
setSendZuulResponse
(
false
);
}
}
else
{
}
else
{
json
.
put
(
"msg"
,
"非法非法"
);
ctx
.
setResponseBody
(
json
.
toString
());
ctx
.
setSendZuulResponse
(
false
);
...
...
@@ -137,6 +130,7 @@ public class PreFilter extends ZuulFilter {
ctx
.
setRequestQueryParams
(
requestQueryParams
);
}
}
ctx
.
setRequestQueryParams
(
requestQueryParams
);
return
null
;
}
...
...
iloomo-ribbon/src/main/resources/application-test.yml
View file @
1df4d739
...
...
@@ -138,3 +138,5 @@ hystrix:
isolation
:
thread
:
timeoutInMilliseconds
:
10000
iloomo
:
debug
:
ture
\ No newline at end of file
iloomo-template/src/main/java/com/iloomo/util/AppUtil.java
View file @
1df4d739
...
...
@@ -3,7 +3,6 @@ package com.iloomo.util;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.serializer.SerializerFeature
;
import
com.iloomo.constant.SysConstant
;
import
org.codehaus.jackson.map.util.JSONPObject
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
...
...
@@ -109,19 +108,7 @@ public class AppUtil {
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
){
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment