forked from 2227324689/Spring-Cloud-Alibaba-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master'
# Conflicts: # markdown/第7章 RocketMQ.md
- Loading branch information
Showing
48 changed files
with
2,138 additions
and
2,050 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
HELP.md | ||
target/ | ||
!.mvn/wrapper/maven-wrapper.jar | ||
!**/src/main/** | ||
!**/src/test/** | ||
|
||
### STS ### | ||
.apt_generated | ||
.classpath | ||
.factorypath | ||
.project | ||
.settings | ||
.springBeans | ||
.sts4-cache | ||
|
||
### IntelliJ IDEA ### | ||
.idea | ||
*.iws | ||
*.iml | ||
*.ipr | ||
|
||
### NetBeans ### | ||
/nbproject/private/ | ||
/nbbuild/ | ||
/dist/ | ||
/nbdist/ | ||
/.nb-gradle/ | ||
build/ | ||
|
||
### VS Code ### | ||
.vscode/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-parent</artifactId> | ||
<version>2.1.1.RELEASE</version> | ||
<relativePath/> <!-- lookup parent from repository --> | ||
</parent> | ||
<groupId>com.gupaoedu.springcloud.gateway</groupId> | ||
<artifactId>spring-cloud-gateway-sample</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
<name>spring-cloud-gateway-sample</name> | ||
<description>Demo project for Spring Boot</description> | ||
|
||
<properties> | ||
<java.version>1.8</java.version> | ||
<spring-cloud.version>Greenwich.SR2</spring-cloud.version> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.cloud</groupId> | ||
<artifactId>spring-cloud-starter</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.cloud</groupId> | ||
<artifactId>spring-cloud-starter-gateway</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-test</artifactId> | ||
<scope>test</scope> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>org.junit.vintage</groupId> | ||
<artifactId>junit-vintage-engine</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.projectlombok</groupId> | ||
<artifactId>lombok</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-data-redis</artifactId> | ||
</dependency> | ||
</dependencies> | ||
|
||
<dependencyManagement> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.cloud</groupId> | ||
<artifactId>spring-cloud-dependencies</artifactId> | ||
<version>${spring-cloud.version}</version> | ||
<type>pom</type> | ||
<scope>import</scope> | ||
</dependency> | ||
</dependencies> | ||
</dependencyManagement> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-maven-plugin</artifactId> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
31 changes: 31 additions & 0 deletions
31
...c/main/java/com/gupaoedu/springcloud/gateway/springcloudgatewaysample/GpDefineFilter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.gupaoedu.springcloud.gateway.springcloudgatewaysample; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.cloud.gateway.filter.GatewayFilterChain; | ||
import org.springframework.cloud.gateway.filter.GlobalFilter; | ||
import org.springframework.core.Ordered; | ||
import org.springframework.core.annotation.Order; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.web.server.ServerWebExchange; | ||
import reactor.core.publisher.Mono; | ||
|
||
/** | ||
* 咕泡学院,只为更好的你 | ||
* 咕泡学院-Mic: 2227324689 | ||
* http://www.gupaoedu.com | ||
**/ | ||
@Service | ||
@Slf4j | ||
public class GpDefineFilter implements GlobalFilter,Ordered{ | ||
@Override | ||
public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) { | ||
log.info("[pre]-Enter GpDefineFilter"); | ||
return chain.filter(exchange).then(Mono.fromRunnable(()->{ | ||
log.info("[post]-Return Result"); | ||
})); | ||
} | ||
@Override | ||
public int getOrder() { | ||
return 0; | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
...m/gupaoedu/springcloud/gateway/springcloudgatewaysample/GpDefineGatewayFilterFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package com.gupaoedu.springcloud.gateway.springcloudgatewaysample; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.cloud.gateway.filter.GatewayFilter; | ||
import org.springframework.cloud.gateway.filter.factory.AbstractGatewayFilterFactory; | ||
import org.springframework.stereotype.Service; | ||
import reactor.core.publisher.Mono; | ||
|
||
/** | ||
* 咕泡学院,只为更好的你 | ||
* 咕泡学院-Mic: 2227324689 | ||
* http://www.gupaoedu.com | ||
**/ | ||
@Service | ||
@Slf4j | ||
public class GpDefineGatewayFilterFactory extends AbstractGatewayFilterFactory<GpDefineGatewayFilterFactory.GpConfig>{ | ||
|
||
public GpDefineGatewayFilterFactory(){ | ||
super(GpConfig.class); | ||
} | ||
|
||
@Override | ||
public GatewayFilter apply(GpConfig config) { | ||
return ((exchange, chain) -> { | ||
log.info("[Pre] Filter Request,name:"+config.getName()); | ||
return chain.filter(exchange).then(Mono.fromRunnable(()->{ | ||
log.info("[Post] Response Filter"); | ||
})); | ||
}); | ||
} | ||
|
||
public static class GpConfig{ | ||
private String name; | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
.../java/com/gupaoedu/springcloud/gateway/springcloudgatewaysample/IpAddressKeyResolver.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.gupaoedu.springcloud.gateway.springcloudgatewaysample; | ||
|
||
import org.springframework.cloud.gateway.filter.ratelimit.KeyResolver; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.web.server.ServerWebExchange; | ||
import reactor.core.publisher.Mono; | ||
|
||
/** | ||
* 咕泡学院,只为更好的你 | ||
* 咕泡学院-Mic: 2227324689 | ||
* http://www.gupaoedu.com | ||
**/ | ||
@Service | ||
public class IpAddressKeyResolver implements KeyResolver{ | ||
@Override | ||
public Mono<String> resolve(ServerWebExchange exchange) { | ||
return Mono.just(exchange.getRequest().getRemoteAddress().getAddress().getHostAddress()); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
...edu/springcloud/gateway/springcloudgatewaysample/SpringCloudGatewaySampleApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.gupaoedu.springcloud.gateway.springcloudgatewaysample; | ||
|
||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
|
||
@SpringBootApplication | ||
public class SpringCloudGatewaySampleApplication { | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(SpringCloudGatewaySampleApplication.class, args); | ||
} | ||
|
||
} |
26 changes: 26 additions & 0 deletions
26
spring-cloud-gateway-sample/src/main/resources/application.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
|
||
spring: | ||
cloud: | ||
gateway: | ||
routes: | ||
- id: define_filter | ||
predicates: | ||
- Path=/gateway/** | ||
filters: | ||
- name: GpDefine | ||
args: | ||
name: Gp_Mic | ||
- name: RequestRateLimiter | ||
args: | ||
denyEmptyKey: false | ||
emptyKeyStatus: SERVICE_UNAVAILABLE | ||
keyResolver: '#{@ipAddressKeyResolver}' | ||
redis-rate-limiter.replenishRate: 1 | ||
redis-rate-limiter.burstCapacity: 2 | ||
- StripPrefix=1 | ||
uri: http://localhost:8080/say | ||
redis: | ||
host: 192.168.216.128 | ||
port: 6379 | ||
server: | ||
port: 8088 |
10 changes: 10 additions & 0 deletions
10
...pringcloud/gateway/springcloudgatewaysample/SpringCloudGatewaySampleApplicationTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.gupaoedu.springcloud.gateway.springcloudgatewaysample; | ||
|
||
import org.springframework.boot.test.context.SpringBootTest; | ||
|
||
@SpringBootTest | ||
class SpringCloudGatewaySampleApplicationTests { | ||
|
||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
HELP.md | ||
target/ | ||
!.mvn/wrapper/maven-wrapper.jar | ||
!**/src/main/** | ||
!**/src/test/** | ||
|
||
### STS ### | ||
.apt_generated | ||
.classpath | ||
.factorypath | ||
.project | ||
.settings | ||
.springBeans | ||
.sts4-cache | ||
|
||
### IntelliJ IDEA ### | ||
.idea | ||
*.iws | ||
*.iml | ||
*.ipr | ||
|
||
### NetBeans ### | ||
/nbproject/private/ | ||
/nbbuild/ | ||
/dist/ | ||
/nbdist/ | ||
/.nb-gradle/ | ||
build/ | ||
|
||
### VS Code ### | ||
.vscode/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-parent</artifactId> | ||
<version>2.2.4.RELEASE</version> | ||
<relativePath/> <!-- lookup parent from repository --> | ||
</parent> | ||
<groupId>com.gupaoedu.springboot.gateway</groupId> | ||
<artifactId>spring-cloud-gateway-service</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
<name>spring-cloud-gateway-service</name> | ||
<description>Demo project for Spring Boot</description> | ||
|
||
<properties> | ||
<java.version>1.8</java.version> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-web</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-test</artifactId> | ||
<scope>test</scope> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>org.junit.vintage</groupId> | ||
<artifactId>junit-vintage-engine</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-maven-plugin</artifactId> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
18 changes: 18 additions & 0 deletions
18
.../main/java/com/gupaoedu/springboot/gateway/springcloudgatewayservice/HelloController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.gupaoedu.springboot.gateway.springcloudgatewayservice; | ||
|
||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
/** | ||
* 咕泡学院,只为更好的你 | ||
* 咕泡学院-Mic: 2227324689 | ||
* http://www.gupaoedu.com | ||
**/ | ||
@RestController | ||
public class HelloController { | ||
|
||
@GetMapping("/say") | ||
public String sayHello(){ | ||
return "[spring-cloud-gateway-service]:say Hello"; | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
...du/springboot/gateway/springcloudgatewayservice/SpringCloudGatewayServiceApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.gupaoedu.springboot.gateway.springcloudgatewayservice; | ||
|
||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
|
||
@SpringBootApplication | ||
public class SpringCloudGatewayServiceApplication { | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(SpringCloudGatewayServiceApplication.class, args); | ||
} | ||
|
||
} |
1 change: 1 addition & 0 deletions
1
spring-cloud-gateway-service/src/main/resources/application.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
spring.application.name=spring-cloud-gateway-service |
13 changes: 13 additions & 0 deletions
13
...ringboot/gateway/springcloudgatewayservice/SpringCloudGatewayServiceApplicationTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.gupaoedu.springboot.gateway.springcloudgatewayservice; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
|
||
@SpringBootTest | ||
class SpringCloudGatewayServiceApplicationTests { | ||
|
||
@Test | ||
void contextLoads() { | ||
} | ||
|
||
} |
Oops, something went wrong.