Skip to content

Commit

Permalink
解决冲突3
Browse files Browse the repository at this point in the history
  • Loading branch information
tangchen.tangchen committed Feb 11, 2020
1 parent 655cfb2 commit 812b6cb
Show file tree
Hide file tree
Showing 26 changed files with 2,138 additions and 104 deletions.
609 changes: 596 additions & 13 deletions spring-boot-dubbo-nacos-sample/.idea/workspace.xml

Large diffs are not rendered by default.

31 changes: 31 additions & 0 deletions spring-cloud-gateway-sample/.gitignore
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/
75 changes: 75 additions & 0 deletions spring-cloud-gateway-sample/pom.xml
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>
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;
}
}
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;
}
}
}
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());
}
}
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 spring-cloud-gateway-sample/src/main/resources/application.yml
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
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 {



}
31 changes: 31 additions & 0 deletions spring-cloud-gateway-service/.gitignore
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/
49 changes: 49 additions & 0 deletions spring-cloud-gateway-service/pom.xml
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>
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";
}
}
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);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
spring.application.name=spring-cloud-gateway-service
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() {
}

}
Loading

0 comments on commit 812b6cb

Please sign in to comment.