Skip to content

Commit 863339f

Browse files
committed
gateway cloud
1 parent 0b0d6f4 commit 863339f

File tree

4 files changed

+27
-27
lines changed

4 files changed

+27
-27
lines changed
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,29 +15,29 @@
1515
* @author fangzhipeng
1616
* create 2018-11-16
1717
**/
18-
public class ElapsedGatewayFilterFactory extends AbstractGatewayFilterFactory<ElapsedGatewayFilterFactory.Config> {
18+
public class RequestTimeGatewayFilterFactory extends AbstractGatewayFilterFactory<RequestTimeGatewayFilterFactory.Config> {
1919

2020

2121
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";
2323
private static final String KEY = "withParams";
2424

2525
@Override
2626
public List<String> shortcutFieldOrder() {
2727
return Arrays.asList(KEY);
2828
}
2929

30-
public ElapsedGatewayFilterFactory() {
30+
public RequestTimeGatewayFilterFactory() {
3131
super(Config.class);
3232
}
3333

3434
@Override
3535
public GatewayFilter apply(Config config) {
3636
return (exchange, chain) -> {
37-
exchange.getAttributes().put(ELAPSED_TIME_BEGIN, System.currentTimeMillis());
37+
exchange.getAttributes().put(REQUEST_TIME_BEGIN, System.currentTimeMillis());
3838
return chain.filter(exchange).then(
3939
Mono.fromRunnable(() -> {
40-
Long startTime = exchange.getAttribute(ELAPSED_TIME_BEGIN);
40+
Long startTime = exchange.getAttribute(REQUEST_TIME_BEGIN);
4141
if (startTime != null) {
4242
StringBuilder sb = new StringBuilder(exchange.getRequest().getURI().getRawPath())
4343
.append(": ")

sc-f-gateway-cloud/service-gateway/src/main/java/com/forezp/servicegateway/ServiceGatewayApplication.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public static void main(String[] args) {
1414
}
1515

1616
@Bean
17-
public ElapsedGatewayFilterFactory elapsedGatewayFilterFactory() {
18-
return new ElapsedGatewayFilterFactory();
17+
public RequestTimeGatewayFilterFactory requestTimeGatewayFilterFactory() {
18+
return new RequestTimeGatewayFilterFactory();
1919
}
2020
}

sc-f-gateway-cloud/service-gateway/src/main/resources/application.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ spring:
88
gateway:
99
discovery:
1010
locator:
11-
enabled: true
11+
enabled: false
1212
lowerCaseServiceId: true
1313
routes:
1414
- id: service-hi
@@ -17,7 +17,7 @@ spring:
1717
- Path=/demo/**
1818
filters:
1919
- StripPrefix=1
20-
- Elapsed=false
20+
- RequestTime=true
2121

2222
eureka:
2323
client:

sc-f-gateway-filter/.idea/workspace.xml

Lines changed: 18 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)