Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 9480be3

Browse files
适应1.0.7
1 parent 25fa2da commit 9480be3

File tree

4 files changed

+35
-5
lines changed
  • base-service/base-demo1-service/base-demo1-base/src/main/java/com/example/demo/base/demo1/service/service
  • business-service/business-demo-service/business-demo-base/src/main
  • product-service/product-demo/product-demo-base/src/main/resources

4 files changed

+35
-5
lines changed

‎base-service/base-demo1-service/base-demo1-base/src/main/java/com/example/demo/base/demo1/service/service/TestServiceImpl.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,13 @@
44
import com.example.demo.base.demo1.contract.service.TestService;
55
import lombok.extern.java.Log;
66
import org.springframework.beans.factory.annotation.Value;
7+
import org.springframework.util.StringUtils;
78
import org.springframework.web.bind.annotation.RequestBody;
89
import org.springframework.web.bind.annotation.RestController;
10+
import org.springframework.web.context.request.RequestContextHolder;
11+
import org.springframework.web.context.request.ServletRequestAttributes;
12+
13+
import javax.servlet.http.HttpServletRequest;
914

1015
/**
1116
* @program: service1
@@ -22,6 +27,12 @@ public class TestServiceImpl implements TestService {
2227

2328
@Override
2429
public String createToken(@RequestBody TestDemoModel model) {
30+
ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
31+
HttpServletRequest request = requestAttributes.getRequest();
32+
String xxx = request.getHeader("xxx");
33+
if(!StringUtils.isEmpty(xxx)){
34+
System.out.println("获取到header xxx:"+xxx);
35+
}
2536
return model.getTestText() + " 》》" + grayTitle;
2637
}
2738
}

‎business-service/business-demo-service/business-demo-base/src/main/java/com/example/demo/business/demo2/service/service/Demo2ServiceImpl.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.example.demo.business.demo2.service.service;
22

33

4-
54
import com.example.demo.base.demo1.contract.feign.TestServiceImpl;
65
import com.example.demo.base.demo1.contract.model.TestDemoModel;
76
import com.example.demo.base.demo4.contract.feign.TestService4Impl;
@@ -12,9 +11,14 @@
1211
import lombok.extern.java.Log;
1312
import org.springframework.beans.factory.annotation.Autowired;
1413
import org.springframework.beans.factory.annotation.Value;
14+
import org.springframework.util.StringUtils;
1515
import org.springframework.web.bind.annotation.RequestBody;
1616
import org.springframework.web.bind.annotation.RequestMapping;
1717
import org.springframework.web.bind.annotation.RestController;
18+
import org.springframework.web.context.request.RequestContextHolder;
19+
import org.springframework.web.context.request.ServletRequestAttributes;
20+
21+
import javax.servlet.http.HttpServletRequest;
1822

1923

2024
/**
@@ -42,6 +46,13 @@ public class Demo2ServiceImpl implements Demo2Service {
4246
@Override
4347
public String validate(@RequestBody Demo2Model model) {
4448

49+
ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
50+
HttpServletRequest request = requestAttributes.getRequest();
51+
String xxx = request.getHeader("xxx");
52+
if(!StringUtils.isEmpty(xxx)){
53+
System.out.println("获取到header xxx:"+xxx);
54+
}
55+
4556
TestDemoModel testDemoModel = new TestDemoModel();
4657
testDemoModel.setTestText(model.getDemo2Name() + " 》》" + grayTitle);
4758
testService.createToken(testDemoModel);

‎business-service/business-demo-service/business-demo-base/src/main/resources/application.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,12 @@ server:
1616
port: ${port:21000}
1717

1818
spring:
19-
#gray:
20-
# deploy:
21-
# ribbonRule: RANDOM
19+
gray:
20+
deploy:
21+
#ribbonRule: RANDOM
22+
transmit:
23+
headers:
24+
- xxx
2225
application:
2326
name: business-demo-service
2427
sleuth:

‎product-service/product-demo/product-demo-base/src/main/resources/application.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,12 @@ server:
1010
spring:
1111
gray:
1212
deploy:
13-
ribbonRule: RANDOM
13+
#ribbonRule: RANDOM
14+
transmit:
15+
headers:
16+
- xxx
17+
18+
1419
application:
1520
name: product-demo
1621
sleuth:

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /