Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
discovery
Overview
Overview
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
谢捷峰
discovery
Commits
34f571e8
Commit
34f571e8
authored
Aug 10, 2018
by
Nepxion
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复Feign上下文的Bug
parent
52c1a804
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
8 deletions
+19
-8
discovery-plugin-strategy-extension-service/src/main/java/com/nepxion/discovery/plugin/strategy/extension/service/aop/FeignStrategyInterceptor.java
+15
-8
discovery-springcloud-example-service/src/main/java/com/nepxion/discovery/plugin/example/service/extension/MyDiscoveryEnabledAdapter.java
+4
-0
No files found.
discovery-plugin-strategy-extension-service/src/main/java/com/nepxion/discovery/plugin/strategy/extension/service/aop/FeignStrategyInterceptor.java
View file @
34f571e8
...
@@ -37,16 +37,23 @@ public class FeignStrategyInterceptor implements RequestInterceptor {
...
@@ -37,16 +37,23 @@ public class FeignStrategyInterceptor implements RequestInterceptor {
@Override
@Override
public
void
apply
(
RequestTemplate
requestTemplate
)
{
public
void
apply
(
RequestTemplate
requestTemplate
)
{
ServletRequestAttributes
attributes
=
(
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
();
ServletRequestAttributes
attributes
=
(
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
();
if
(
attributes
==
null
)
{
return
;
}
HttpServletRequest
request
=
attributes
.
getRequest
();
HttpServletRequest
request
=
attributes
.
getRequest
();
Enumeration
<
String
>
headerNames
=
request
.
getHeaderNames
();
Enumeration
<
String
>
headerNames
=
request
.
getHeaderNames
();
if
(
headerNames
!=
null
)
{
if
(
headerNames
==
null
)
{
while
(
headerNames
.
hasMoreElements
())
{
return
;
String
headerName
=
headerNames
.
nextElement
();
}
String
header
=
request
.
getHeader
(
headerName
);
while
(
headerNames
.
hasMoreElements
())
{
if
(
feignHeaders
.
contains
(
headerName
))
{
String
headerName
=
headerNames
.
nextElement
();
requestTemplate
.
header
(
headerName
,
header
);
String
header
=
request
.
getHeader
(
headerName
);
}
if
(
feignHeaders
.
contains
(
headerName
))
{
requestTemplate
.
header
(
headerName
,
header
);
}
}
}
}
}
}
...
...
discovery-springcloud-example-service/src/main/java/com/nepxion/discovery/plugin/example/service/extension/MyDiscoveryEnabledAdapter.java
View file @
34f571e8
...
@@ -65,6 +65,10 @@ public class MyDiscoveryEnabledAdapter implements DiscoveryEnabledAdapter {
...
@@ -65,6 +65,10 @@ public class MyDiscoveryEnabledAdapter implements DiscoveryEnabledAdapter {
private
boolean
applyFromHeader
(
Server
server
,
Map
<
String
,
String
>
metadata
)
{
private
boolean
applyFromHeader
(
Server
server
,
Map
<
String
,
String
>
metadata
)
{
ServletRequestAttributes
attributes
=
(
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
();
ServletRequestAttributes
attributes
=
(
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
();
if
(
attributes
==
null
)
{
return
true
;
}
String
token
=
attributes
.
getRequest
().
getHeader
(
"token"
);
String
token
=
attributes
.
getRequest
().
getHeader
(
"token"
);
// String value = attributes.getRequest().getParameter("value");
// String value = attributes.getRequest().getParameter("value");
...
...
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