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
39474ed1
Commit
39474ed1
authored
May 09, 2019
by
Nepxion
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
简化服务和网关上下文获取Header的方式
parent
f6dd9831
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
0 deletions
+27
-0
discovery-plugin-strategy-starter-zuul/src/main/java/com/nepxion/discovery/plugin/strategy/zuul/filter/ZuulStrategyFilterResolver.java
+27
-0
No files found.
discovery-plugin-strategy-starter-zuul/src/main/java/com/nepxion/discovery/plugin/strategy/zuul/filter/ZuulStrategyFilterResolver.java
0 → 100644
View file @
39474ed1
package
com
.
nepxion
.
discovery
.
plugin
.
strategy
.
zuul
.
filter
;
/**
* <p>Title: Nepxion Discovery</p>
* <p>Description: Nepxion Discovery</p>
* <p>Copyright: Copyright (c) 2017-2050</p>
* <p>Company: Nepxion</p>
* @author Haojun Ren
* @version 1.0
*/
import
org.apache.commons.lang3.StringUtils
;
import
com.netflix.zuul.context.RequestContext
;
public
class
ZuulStrategyFilterResolver
{
public
static
void
setHeader
(
String
headerName
,
String
headerValue
)
{
RequestContext
context
=
RequestContext
.
getCurrentContext
();
// 来自于外界的Header,例如,从Postman传递过来的Header
String
header
=
context
.
getRequest
().
getHeader
(
headerName
);
if
(
StringUtils
.
isEmpty
(
header
))
{
context
.
addZuulRequestHeader
(
headerName
,
headerValue
);
}
}
}
\ No newline at end of file
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