GeezerVison is showing github.com — gateway cloud · thjjava/SpringCloudLearning@863339f
File tree
Expand file treeCollapse file tree
Open diff view settings
sc-f-gateway-cloud/service-gateway/src/main java/com/forezp/servicegateway
sc-f-gateway-filter/.idea
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: sc-f-gateway-cloud/service-gateway/src/main/java/com/forezp/servicegateway/RequestTimeGatewayFilterFactory.java +5-5Lines changed: 5 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
|
15 | 15 | * @author fangzhipeng |
16 | 16 | * create 2018-11-16 |
17 | 17 | **/ |
18 | | -public class ElapsedGatewayFilterFactory extends AbstractGatewayFilterFactory<ElapsedGatewayFilterFactory.Config> { |
| 18 | +public class RequestTimeGatewayFilterFactory extends AbstractGatewayFilterFactory<RequestTimeGatewayFilterFactory.Config> { |
19 | 19 |
|
20 | 20 |
|
21 | 21 | private static final Log log = LogFactory.getLog(GatewayFilter.class); |
22 | | - private static final String ELAPSED_TIME_BEGIN = "elapsedTimeBegin"; |
| 22 | + private static final String REQUEST_TIME_BEGIN = "requestTimeBegin"; |
23 | 23 | private static final String KEY = "withParams"; |
24 | 24 |
|
25 | 25 | @Override |
26 | 26 | public List<String> shortcutFieldOrder() { |
27 | 27 | return Arrays.asList(KEY); |
28 | 28 | } |
29 | 29 |
|
30 | | - public ElapsedGatewayFilterFactory() { |
| 30 | + public RequestTimeGatewayFilterFactory() { |
31 | 31 | super(Config.class); |
32 | 32 | } |
33 | 33 |
|
34 | 34 | @Override |
35 | 35 | public GatewayFilter apply(Config config) { |
36 | 36 | return (exchange, chain) -> { |
37 | | - exchange.getAttributes().put(ELAPSED_TIME_BEGIN, System.currentTimeMillis()); |
| 37 | + exchange.getAttributes().put(REQUEST_TIME_BEGIN, System.currentTimeMillis()); |
38 | 38 | return chain.filter(exchange).then( |
39 | 39 | Mono.fromRunnable(() -> { |
40 | | - Long startTime = exchange.getAttribute(ELAPSED_TIME_BEGIN); |
| 40 | + Long startTime = exchange.getAttribute(REQUEST_TIME_BEGIN); |
41 | 41 | if (startTime != null) { |
42 | 42 | StringBuilder sb = new StringBuilder(exchange.getRequest().getURI().getRawPath()) |
43 | 43 | .append(": ") |
|
Collapse file
Copy file name to clipboardExpand all lines: sc-f-gateway-cloud/service-gateway/src/main/java/com/forezp/servicegateway/ServiceGatewayApplication.java +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -14,7 +14,7 @@ public static void main(String[] args) { |
14 | 14 | } |
15 | 15 |
|
16 | 16 | @Bean |
17 | | - public ElapsedGatewayFilterFactory elapsedGatewayFilterFactory() { |
18 | | - return new ElapsedGatewayFilterFactory(); |
| 17 | + public RequestTimeGatewayFilterFactory requestTimeGatewayFilterFactory() { |
| 18 | + return new RequestTimeGatewayFilterFactory(); |
19 | 19 | } |
20 | 20 | } |
Collapse file
Copy file name to clipboardExpand all lines: sc-f-gateway-cloud/service-gateway/src/main/resources/application.yml +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
|
8 | 8 | gateway: |
9 | 9 | discovery: |
10 | 10 | locator: |
11 | | - enabled: true |
| 11 | + enabled: false |
12 | 12 | lowerCaseServiceId: true |
13 | 13 | routes: |
14 | 14 | - id: service-hi |
@@ -17,7 +17,7 @@ spring: |
17 | 17 | - Path=/demo/** |
18 | 18 | filters: |
19 | 19 | - StripPrefix=1 |
20 | | - - Elapsed=false |
| 20 | + - RequestTime=true |
21 | 21 |
|
22 | 22 | eureka: |
23 | 23 | client: |
|
Collapse file
Copy file name to clipboardExpand all lines: sc-f-gateway-filter/.idea/workspace.xml +18-18Lines changed: 18 additions & 18 deletions