Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 976a37b

Browse files
committed
ad
1 parent 3b03483 commit 976a37b

File tree

4 files changed

+138
-0
lines changed

4 files changed

+138
-0
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
6+
<groupId>com.neo</groupId>
7+
<artifactId>cloud-gateway</artifactId>
8+
<version>0.0.1-SNAPSHOT</version>
9+
<packaging>jar</packaging>
10+
11+
<name>cloud-gateway</name>
12+
<description>Demo project for Spring Boot</description>
13+
14+
<parent>
15+
<groupId>org.springframework.boot</groupId>
16+
<artifactId>spring-boot-starter-parent</artifactId>
17+
<version>2.0.6.RELEASE</version>
18+
<relativePath/> <!-- lookup parent from repository -->
19+
</parent>
20+
21+
<dependencyManagement>
22+
<dependencies>
23+
<dependency>
24+
<groupId>org.springframework.cloud</groupId>
25+
<artifactId>spring-cloud-dependencies</artifactId>
26+
<version>Finchley.SR2</version>
27+
<type>pom</type>
28+
<scope>import</scope>
29+
</dependency>
30+
</dependencies>
31+
</dependencyManagement>
32+
33+
<dependencies>
34+
<dependency>
35+
<groupId>org.springframework.cloud</groupId>
36+
<artifactId>spring-cloud-starter-gateway</artifactId>
37+
</dependency>
38+
<dependency>
39+
<groupId>org.springframework.boot</groupId>
40+
<artifactId>spring-boot-starter-test</artifactId>
41+
<scope>test</scope>
42+
</dependency>
43+
</dependencies>
44+
45+
<build>
46+
<plugins>
47+
<plugin>
48+
<groupId>org.springframework.boot</groupId>
49+
<artifactId>spring-boot-maven-plugin</artifactId>
50+
</plugin>
51+
</plugins>
52+
</build>
53+
54+
</project>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.neo;
2+
3+
import org.springframework.boot.SpringApplication;
4+
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
import org.springframework.cloud.gateway.route.RouteLocator;
6+
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
7+
import org.springframework.context.annotation.Bean;
8+
9+
@SpringBootApplication
10+
public class GateWayApplication {
11+
12+
public static void main(String[] args) {
13+
SpringApplication.run(GateWayApplication.class, args);
14+
}
15+
16+
@Bean
17+
public RouteLocator customRouteLocator(RouteLocatorBuilder builder) {
18+
return builder.routes()
19+
.route("path_route", r -> r.path("/about")
20+
.uri("http://ityouknow.com"))
21+
.build();
22+
}
23+
24+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
server:
2+
port: 8080
3+
spring:
4+
cloud:
5+
gateway:
6+
routes:
7+
- id: neo_route
8+
uri: http://www.ityouknow.com
9+
predicates:
10+
- Path=/spring-cloud
11+
# - id: time_route
12+
# uri: http://ityouknow.com
13+
# predicates:
14+
# - After=2018-01-20T06:06:06+08:00[Asia/Shanghai]
15+
# - Before=2018-01-20T06:06:06+08:00[Asia/Shanghai]
16+
# - Between=2018-01-20T06:06:06+08:00[Asia/Shanghai], 2019-01-20T06:06:06+08:00[Asia/Shanghai]
17+
# - id: cookie_route
18+
# uri: http://ityouknow.com
19+
# predicates:
20+
# - Cookie=ityouknow, kee.e
21+
# - id: header_route
22+
# uri: http://ityouknow.com
23+
# predicates:
24+
# - Header=X-Request-Id, \d+
25+
# - id: host_route
26+
# uri: http://ityouknow.com
27+
# predicates:
28+
# - Host=**.ityouknow.com
29+
# - id: method_route
30+
# uri: http://ityouknow.com
31+
# predicates:
32+
# - Method=GET
33+
# - id: host_route
34+
# uri: http://ityouknow.com
35+
# predicates:
36+
# - Path=/foo/{segment}
37+
# - id: query_route
38+
# uri: http://ityouknow.com
39+
# predicates:
40+
# - Query=keep, pu.
41+
# - id: remoteaddr_route
42+
# uri: http://ityouknow.com
43+
# predicates:
44+
# - RemoteAddr=192.168.126.218/24
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.neo;
2+
3+
import org.junit.Test;
4+
import org.junit.runner.RunWith;
5+
import org.springframework.boot.test.context.SpringBootTest;
6+
import org.springframework.test.context.junit4.SpringRunner;
7+
8+
@RunWith(SpringRunner.class)
9+
@SpringBootTest
10+
public class GateWayApplicationTests {
11+
12+
@Test
13+
public void contextLoads() {
14+
}
15+
16+
}

0 commit comments

Comments
 (0)