api-gateway-netflix-zuul
DerekYRC 2 years ago
parent 0c6fb4da0b
commit 168056ce1f

@ -0,0 +1,43 @@
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>mini-spring-cloud</artifactId>
<groupId>com.github</groupId>
<version>1.0.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>mini-spring-cloud-api-gateway-example</artifactId>
<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>
</dependency>
<dependency>
<groupId>com.github</groupId>
<artifactId>mini-spring-cloud-netflix-zuul</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>

@ -0,0 +1,19 @@
package com.github.cloud.examples;
import com.github.cloud.netflix.zuul.EnableZuulProxy;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
* @author derek()
* @date 2022/6/26
*/
@EnableZuulProxy
@SpringBootApplication
public class ApiGatewayApplication {
public static void main(String[] args) {
SpringApplication.run(ApiGatewayApplication.class, args);
}
}

@ -10,7 +10,6 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>mini-spring-cloud-netflix-zuul</artifactId>
<version>1.0.0-SNAPSHOT</version>
<dependencies>
<dependency>
@ -55,7 +54,6 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<scope>test</scope>
</dependency>
<dependency>

@ -26,6 +26,6 @@ public class ZuulServerAutoConfiguration {
*/
@Bean
public ServletRegistrationBean zuulServlet() {
return new ServletRegistrationBean<>(new ZuulServlet(), zuulProperties.getServletPattern());
return new ServletRegistrationBean<>(new ZuulServlet(), zuulProperties.getServletPath());
}
}

@ -9,25 +9,13 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
@ConfigurationProperties("zuul")
public class ZuulProperties {
private String servletPath = "/zuul";
private String servletPath = "/zuul/*";
public String getServletPattern() {
String path = this.servletPath;
if (!path.startsWith("/")) {
path = "/" + path;
}
if (!path.contains("*")) {
path = path.endsWith("/") ? (path + "*") : (path + "/*");
}
return path;
}
String getServletPath() {
public String getServletPath() {
return servletPath;
}
void setServletPath(String servletPath) {
public void setServletPath(String servletPath) {
this.servletPath = servletPath;
}
}

@ -17,13 +17,14 @@
<version>1.0.0-SNAPSHOT</version>
<modules>
<module>mini-spring-cloud-examples/tutu-server</module>
<module>mini-spring-cloud-tutu-discovery</module>
<module>mini-spring-cloud-examples/mini-spring-cloud-provider-example</module>
<module>mini-spring-cloud-examples/mini-spring-cloud-consumer-examples</module>
<module>mini-spring-cloud-load-balancer</module>
<module>mini-spring-cloud-openfeign</module>
<module>mini-spring-cloud-netflix-zuul</module>
<module>mini-spring-cloud-examples/tutu-server</module>
<module>mini-spring-cloud-examples/mini-spring-cloud-provider-example</module>
<module>mini-spring-cloud-examples/mini-spring-cloud-consumer-examples</module>
<module>mini-spring-cloud-examples/mini-spring-cloud-api-gateway-example</module>
</modules>
<properties>

Loading…
Cancel
Save