Skip to content

Commit

Permalink
gateway cloud
Browse files Browse the repository at this point in the history
  • Loading branch information
forezp committed Nov 19, 2018
1 parent 0f1ba1e commit 0b0d6f4
Show file tree
Hide file tree
Showing 14 changed files with 230 additions and 139 deletions.
2 changes: 1 addition & 1 deletion sc-f-gateway-cloud/eureka-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<parent>
<groupId>com.forezp</groupId>
<artifactId>sc-f-chapter1</artifactId>
<artifactId>sc-f-gateway-cloud</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>

Expand Down
1 change: 1 addition & 0 deletions sc-f-gateway-cloud/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<modules>
<module>eureka-server</module>
<module>service-hi</module>
<module>service-gateway</module>
</modules>

<properties>
Expand Down
31 changes: 5 additions & 26 deletions sc-f-gateway-cloud/service-gateway/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,19 @@
<description>Demo project for Spring Boot</description>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.0.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
<groupId>com.forezp</groupId>
<artifactId>sc-f-gateway-cloud</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<spring-cloud.version>Greenwich.M1</spring-cloud.version>
</properties>

<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-gateway</artifactId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
<artifactId>spring-cloud-starter-gateway</artifactId>
</dependency>

<dependency>
Expand All @@ -42,18 +34,6 @@
</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>
Expand All @@ -74,5 +54,4 @@
</repository>
</repositories>


</project>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package gateway;
package com.forezp.servicegateway;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,19 @@

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.context.annotation.Bean;

@SpringBootApplication
@EnableEurekaClient
public class ServiceGatewayApplication {

public static void main(String[] args) {
SpringApplication.run( ServiceGatewayApplication.class, args );
}

@Bean
public ElapsedGatewayFilterFactory elapsedGatewayFilterFactory() {
return new ElapsedGatewayFilterFactory();
}
}
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
server:
port: 8081

spring:
application:
name: sc-gateway-server
cloud:
gateway:
discovery:
locator:
enabled: true
lowerCaseServiceId: true
routes:
- id: service-hi
uri: lb://SERVICE-HI
predicates:
- Path=/demo/**
filters:
- StripPrefix=1
- Elapsed=false

eureka:
client:
service-url:
defaultZone: http://localhost:8761/eureka/

logging:
level:
org.springframework.cloud.gateway: debug



2 changes: 1 addition & 1 deletion sc-f-gateway-cloud/service-hi/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<parent>
<groupId>com.forezp</groupId>
<artifactId>sc-f-chapter1</artifactId>
<artifactId>sc-f-gateway-cloud</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ public String home(@RequestParam(value = "name", defaultValue = "forezp") String
return "hi " + name + " ,i am from port:" + port;
}


// @RequestMapping("/demo/hi")
// public String qsw(@RequestParam(value = "name", defaultValue = "forezp") String name) {
// return "hi " + name + " ,i am from port:" + port;
// }
}


Expand Down
Loading

0 comments on commit 0b0d6f4

Please sign in to comment.