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
8fc4fc27
Commit
8fc4fc27
authored
Apr 23, 2019
by
Nepxion
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
框架内置的三个Http Header加前缀n-d-,避免和业务系统冲突,分别是"n-d-region", "n-d-version", "n-d-address"
parent
4954ef0a
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
29 additions
and
23 deletions
+29
-23
discovery-common/src/main/java/com/nepxion/discovery/common/constant/DiscoveryConstant.java
+5
-2
discovery-plugin-strategy-starter-gateway/src/main/java/com/nepxion/discovery/plugin/strategy/gateway/adapter/DefaultDiscoveryEnabledAdapter.java
+4
-3
discovery-plugin-strategy-starter-service/src/main/java/com/nepxion/discovery/plugin/strategy/service/adapter/DefaultDiscoveryEnabledAdapter.java
+4
-3
discovery-plugin-strategy-starter-service/src/main/java/com/nepxion/discovery/plugin/strategy/service/aop/FeignStrategyInterceptor.java
+6
-6
discovery-plugin-strategy-starter-service/src/main/java/com/nepxion/discovery/plugin/strategy/service/aop/RestTemplateStrategyInterceptor.java
+6
-6
discovery-plugin-strategy-starter-zuul/src/main/java/com/nepxion/discovery/plugin/strategy/zuul/adapter/DefaultDiscoveryEnabledAdapter.java
+4
-3
No files found.
discovery-common/src/main/java/com/nepxion/discovery/common/constant/DiscoveryConstant.java
View file @
8fc4fc27
...
@@ -24,18 +24,21 @@ public class DiscoveryConstant {
...
@@ -24,18 +24,21 @@ public class DiscoveryConstant {
public
static
final
String
SPRING_APPLICATION_NAME
=
"spring.application.name"
;
public
static
final
String
SPRING_APPLICATION_NAME
=
"spring.application.name"
;
public
static
final
String
GROUP
=
"group"
;
public
static
final
String
GROUP
=
"group"
;
public
static
final
String
REGION
=
"region"
;
public
static
final
String
ADDRESS
=
"address"
;
public
static
final
String
SERVICE_ID
=
"serviceId"
;
public
static
final
String
SERVICE_ID
=
"serviceId"
;
public
static
final
String
HOST
=
"host"
;
public
static
final
String
HOST
=
"host"
;
public
static
final
String
PORT
=
"port"
;
public
static
final
String
PORT
=
"port"
;
public
static
final
String
METADATA
=
"metadata"
;
public
static
final
String
METADATA
=
"metadata"
;
public
static
final
String
REGION
=
"region"
;
public
static
final
String
VERSION
=
"version"
;
public
static
final
String
VERSION
=
"version"
;
public
static
final
String
DYNAMIC_VERSION
=
"dynamicVersion"
;
public
static
final
String
DYNAMIC_VERSION
=
"dynamicVersion"
;
public
static
final
String
RULE
=
"rule"
;
public
static
final
String
RULE
=
"rule"
;
public
static
final
String
DYNAMIC_RULE
=
"dynamicRule"
;
public
static
final
String
DYNAMIC_RULE
=
"dynamicRule"
;
public
static
final
String
REACH_MAX_LIMITED_COUNT
=
"reach max limited count"
;
public
static
final
String
REACH_MAX_LIMITED_COUNT
=
"reach max limited count"
;
public
static
final
String
N_D_REGION
=
"n-d-region"
;
public
static
final
String
N_D_VERSION
=
"n-d-version"
;
public
static
final
String
N_D_ADDRESS
=
"n-d-address"
;
public
static
final
String
XML_FORMAT
=
"xml"
;
public
static
final
String
XML_FORMAT
=
"xml"
;
public
static
final
String
JSON_FORMAT
=
"json"
;
public
static
final
String
JSON_FORMAT
=
"json"
;
public
static
final
String
PREFIX_CLASSPATH
=
"classpath:"
;
public
static
final
String
PREFIX_CLASSPATH
=
"classpath:"
;
...
...
discovery-plugin-strategy-starter-gateway/src/main/java/com/nepxion/discovery/plugin/strategy/gateway/adapter/DefaultDiscoveryEnabledAdapter.java
View file @
8fc4fc27
...
@@ -36,7 +36,7 @@ public class DefaultDiscoveryEnabledAdapter extends AbstractDiscoveryEnabledAdap
...
@@ -36,7 +36,7 @@ public class DefaultDiscoveryEnabledAdapter extends AbstractDiscoveryEnabledAdap
return
null
;
return
null
;
}
}
return
exchange
.
getRequest
().
getHeaders
().
getFirst
(
DiscoveryConstant
.
VERSION
);
return
exchange
.
getRequest
().
getHeaders
().
getFirst
(
DiscoveryConstant
.
N_D_
VERSION
);
}
}
@Override
@Override
...
@@ -50,7 +50,7 @@ public class DefaultDiscoveryEnabledAdapter extends AbstractDiscoveryEnabledAdap
...
@@ -50,7 +50,7 @@ public class DefaultDiscoveryEnabledAdapter extends AbstractDiscoveryEnabledAdap
return
null
;
return
null
;
}
}
return
exchange
.
getRequest
().
getHeaders
().
getFirst
(
DiscoveryConstant
.
REGION
);
return
exchange
.
getRequest
().
getHeaders
().
getFirst
(
DiscoveryConstant
.
N_D_
REGION
);
}
}
@Override
@Override
...
@@ -64,6 +64,6 @@ public class DefaultDiscoveryEnabledAdapter extends AbstractDiscoveryEnabledAdap
...
@@ -64,6 +64,6 @@ public class DefaultDiscoveryEnabledAdapter extends AbstractDiscoveryEnabledAdap
return
null
;
return
null
;
}
}
return
exchange
.
getRequest
().
getHeaders
().
getFirst
(
DiscoveryConstant
.
ADDRESS
);
return
exchange
.
getRequest
().
getHeaders
().
getFirst
(
DiscoveryConstant
.
N_D_
ADDRESS
);
}
}
}
}
\ No newline at end of file
discovery-plugin-strategy-starter-service/src/main/java/com/nepxion/discovery/plugin/strategy/service/adapter/DefaultDiscoveryEnabledAdapter.java
View file @
8fc4fc27
...
@@ -36,7 +36,7 @@ public class DefaultDiscoveryEnabledAdapter extends AbstractDiscoveryEnabledAdap
...
@@ -36,7 +36,7 @@ public class DefaultDiscoveryEnabledAdapter extends AbstractDiscoveryEnabledAdap
return
null
;
return
null
;
}
}
return
attributes
.
getRequest
().
getHeader
(
DiscoveryConstant
.
VERSION
);
return
attributes
.
getRequest
().
getHeader
(
DiscoveryConstant
.
N_D_
VERSION
);
}
}
@Override
@Override
...
@@ -50,7 +50,7 @@ public class DefaultDiscoveryEnabledAdapter extends AbstractDiscoveryEnabledAdap
...
@@ -50,7 +50,7 @@ public class DefaultDiscoveryEnabledAdapter extends AbstractDiscoveryEnabledAdap
return
null
;
return
null
;
}
}
return
attributes
.
getRequest
().
getHeader
(
DiscoveryConstant
.
REGION
);
return
attributes
.
getRequest
().
getHeader
(
DiscoveryConstant
.
N_D_
REGION
);
}
}
@Override
@Override
...
@@ -64,6 +64,6 @@ public class DefaultDiscoveryEnabledAdapter extends AbstractDiscoveryEnabledAdap
...
@@ -64,6 +64,6 @@ public class DefaultDiscoveryEnabledAdapter extends AbstractDiscoveryEnabledAdap
return
null
;
return
null
;
}
}
return
attributes
.
getRequest
().
getHeader
(
DiscoveryConstant
.
ADDRESS
);
return
attributes
.
getRequest
().
getHeader
(
DiscoveryConstant
.
N_D_
ADDRESS
);
}
}
}
}
\ No newline at end of file
discovery-plugin-strategy-starter-service/src/main/java/com/nepxion/discovery/plugin/strategy/service/aop/FeignStrategyInterceptor.java
View file @
8fc4fc27
...
@@ -47,14 +47,14 @@ public class FeignStrategyInterceptor implements RequestInterceptor {
...
@@ -47,14 +47,14 @@ public class FeignStrategyInterceptor implements RequestInterceptor {
if
(
StringUtils
.
isNotEmpty
(
requestHeaders
))
{
if
(
StringUtils
.
isNotEmpty
(
requestHeaders
))
{
requestHeaderList
.
addAll
(
StringUtil
.
splitToList
(
requestHeaders
.
toLowerCase
(),
DiscoveryConstant
.
SEPARATE
));
requestHeaderList
.
addAll
(
StringUtil
.
splitToList
(
requestHeaders
.
toLowerCase
(),
DiscoveryConstant
.
SEPARATE
));
}
}
if
(!
requestHeaderList
.
contains
(
DiscoveryConstant
.
VERSION
))
{
if
(!
requestHeaderList
.
contains
(
DiscoveryConstant
.
N_D_
VERSION
))
{
requestHeaderList
.
add
(
DiscoveryConstant
.
VERSION
);
requestHeaderList
.
add
(
DiscoveryConstant
.
N_D_
VERSION
);
}
}
if
(!
requestHeaderList
.
contains
(
DiscoveryConstant
.
REGION
))
{
if
(!
requestHeaderList
.
contains
(
DiscoveryConstant
.
N_D_
REGION
))
{
requestHeaderList
.
add
(
DiscoveryConstant
.
REGION
);
requestHeaderList
.
add
(
DiscoveryConstant
.
N_D_
REGION
);
}
}
if
(!
requestHeaderList
.
contains
(
DiscoveryConstant
.
ADDRESS
))
{
if
(!
requestHeaderList
.
contains
(
DiscoveryConstant
.
N_D_
ADDRESS
))
{
requestHeaderList
.
add
(
DiscoveryConstant
.
ADDRESS
);
requestHeaderList
.
add
(
DiscoveryConstant
.
N_D_
ADDRESS
);
}
}
LOG
.
info
(
"Feign intercepted headers are {}"
,
StringUtils
.
isNotEmpty
(
requestHeaders
)
?
requestHeaders
:
"empty"
);
LOG
.
info
(
"Feign intercepted headers are {}"
,
StringUtils
.
isNotEmpty
(
requestHeaders
)
?
requestHeaders
:
"empty"
);
LOG
.
info
(
"-------------------------------------------------"
);
LOG
.
info
(
"-------------------------------------------------"
);
...
...
discovery-plugin-strategy-starter-service/src/main/java/com/nepxion/discovery/plugin/strategy/service/aop/RestTemplateStrategyInterceptor.java
View file @
8fc4fc27
...
@@ -50,14 +50,14 @@ public class RestTemplateStrategyInterceptor implements ClientHttpRequestInterce
...
@@ -50,14 +50,14 @@ public class RestTemplateStrategyInterceptor implements ClientHttpRequestInterce
if
(
StringUtils
.
isNotEmpty
(
requestHeaders
))
{
if
(
StringUtils
.
isNotEmpty
(
requestHeaders
))
{
requestHeaderList
.
addAll
(
StringUtil
.
splitToList
(
requestHeaders
.
toLowerCase
(),
DiscoveryConstant
.
SEPARATE
));
requestHeaderList
.
addAll
(
StringUtil
.
splitToList
(
requestHeaders
.
toLowerCase
(),
DiscoveryConstant
.
SEPARATE
));
}
}
if
(!
requestHeaderList
.
contains
(
DiscoveryConstant
.
VERSION
))
{
if
(!
requestHeaderList
.
contains
(
DiscoveryConstant
.
N_D_
VERSION
))
{
requestHeaderList
.
add
(
DiscoveryConstant
.
VERSION
);
requestHeaderList
.
add
(
DiscoveryConstant
.
N_D_
VERSION
);
}
}
if
(!
requestHeaderList
.
contains
(
DiscoveryConstant
.
REGION
))
{
if
(!
requestHeaderList
.
contains
(
DiscoveryConstant
.
N_D_
REGION
))
{
requestHeaderList
.
add
(
DiscoveryConstant
.
REGION
);
requestHeaderList
.
add
(
DiscoveryConstant
.
N_D_
REGION
);
}
}
if
(!
requestHeaderList
.
contains
(
DiscoveryConstant
.
ADDRESS
))
{
if
(!
requestHeaderList
.
contains
(
DiscoveryConstant
.
N_D_
ADDRESS
))
{
requestHeaderList
.
add
(
DiscoveryConstant
.
ADDRESS
);
requestHeaderList
.
add
(
DiscoveryConstant
.
N_D_
ADDRESS
);
}
}
LOG
.
info
(
"RestTemplate intercepted headers are {}"
,
StringUtils
.
isNotEmpty
(
requestHeaders
)
?
requestHeaders
:
"empty"
);
LOG
.
info
(
"RestTemplate intercepted headers are {}"
,
StringUtils
.
isNotEmpty
(
requestHeaders
)
?
requestHeaders
:
"empty"
);
LOG
.
info
(
"-------------------------------------------------"
);
LOG
.
info
(
"-------------------------------------------------"
);
...
...
discovery-plugin-strategy-starter-zuul/src/main/java/com/nepxion/discovery/plugin/strategy/zuul/adapter/DefaultDiscoveryEnabledAdapter.java
View file @
8fc4fc27
...
@@ -37,7 +37,7 @@ public class DefaultDiscoveryEnabledAdapter extends AbstractDiscoveryEnabledAdap
...
@@ -37,7 +37,7 @@ public class DefaultDiscoveryEnabledAdapter extends AbstractDiscoveryEnabledAdap
return
null
;
return
null
;
}
}
return
request
.
getHeader
(
DiscoveryConstant
.
VERSION
);
return
request
.
getHeader
(
DiscoveryConstant
.
N_D_
VERSION
);
}
}
@Override
@Override
...
@@ -51,7 +51,7 @@ public class DefaultDiscoveryEnabledAdapter extends AbstractDiscoveryEnabledAdap
...
@@ -51,7 +51,7 @@ public class DefaultDiscoveryEnabledAdapter extends AbstractDiscoveryEnabledAdap
return
null
;
return
null
;
}
}
return
request
.
getHeader
(
DiscoveryConstant
.
REGION
);
return
request
.
getHeader
(
DiscoveryConstant
.
N_D_
REGION
);
}
}
@Override
@Override
...
@@ -65,6 +65,6 @@ public class DefaultDiscoveryEnabledAdapter extends AbstractDiscoveryEnabledAdap
...
@@ -65,6 +65,6 @@ public class DefaultDiscoveryEnabledAdapter extends AbstractDiscoveryEnabledAdap
return
null
;
return
null
;
}
}
return
request
.
getHeader
(
DiscoveryConstant
.
ADDRESS
);
return
request
.
getHeader
(
DiscoveryConstant
.
N_D_
ADDRESS
);
}
}
}
}
\ 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