构建 spring cloud gateway && zuul 容器测试示例

This commit is contained in:
YunaiV
2019-06-01 09:16:13 +08:00
parent 8fedee504c
commit 891a049ea5
5 changed files with 14 additions and 0 deletions

View File

@@ -11,4 +11,10 @@ public class Controller {
return "world";
}
@GetMapping("/sleep")
public String sleep() throws InterruptedException {
Thread.sleep(100L);
return "sleep";
}
}

View File

@@ -12,6 +12,7 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>lab-07-spring-cloud-gateway</artifactId>
<version>1.0.0</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

View File

@@ -12,6 +12,8 @@ public class SpringCloudGatewayApplication {
@Bean
public RouteLocator myRouteLocator(RouteLocatorBuilder builder) {
return builder.routes()
.route(r -> r.path("/hello.txt")
.uri("http://localhost:8000/hello.txt"))
.route(r -> r.path("/**")
.uri("http://localhost:8080"))
.build();

View File

@@ -12,6 +12,7 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>lab-07-zuul</artifactId>
<version>1.0.0</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

View File

@@ -1,6 +1,10 @@
zuul:
routes:
static:
path: /hello.txt
url: http://127.0.0.1:8000/
stripPrefix: false
api:
path: /**
url: http://127.0.0.1:8080
include-debug-header: true