mirror of
https://gitee.com/yudaocode/SpringBoot-Labs.git
synced 2026-09-03 05:53:54 +08:00
构建 spring cloud gateway && zuul 容器测试示例
This commit is contained in:
@@ -11,4 +11,10 @@ public class Controller {
|
||||
return "world";
|
||||
}
|
||||
|
||||
@GetMapping("/sleep")
|
||||
public String sleep() throws InterruptedException {
|
||||
Thread.sleep(100L);
|
||||
return "sleep";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user