Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Spring Boot 2 #19

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<groupId>com.github.mthizo247</groupId>
<artifactId>spring-cloud-netflix-zuul-websocket</artifactId>
<packaging>jar</packaging>
<version>1.0.7.RELEASE</version>
<version>2.0.0.RELEASE</version>
<name>Spring Cloud Netflix Zuul Websocket</name>
<description>Spring Cloud Netflix Zuul Websocket</description>
<url>https://www.discovery.co.za</url>
Expand Down Expand Up @@ -52,13 +52,13 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.10.RELEASE</version>
<version>2.0.4.RELEASE</version>
<relativePath/>
</parent>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.7</java.version>
<java.version>1.8</java.version>
</properties>

<distributionManagement>
Expand All @@ -80,8 +80,8 @@
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-zuul</artifactId>
<version>1.1.5.RELEASE</version>
<artifactId>spring-cloud-starter-netflix-zuul</artifactId>
<version>2.0.1.RELEASE</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand All @@ -92,6 +92,7 @@
<dependency>
<groupId>org.springframework.security.oauth</groupId>
<artifactId>spring-security-oauth2</artifactId>
<version>2.2.1.RELEASE</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
package com.github.mthizo247.cloud.netflix.zuul.web.proxytarget;

import com.github.mthizo247.cloud.netflix.zuul.web.socket.ZuulWebSocketProperties;
import com.github.mthizo247.cloud.netflix.zuul.web.util.MapPropertyResolver;
import org.springframework.boot.bind.RelaxedPropertyResolver;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.netflix.zuul.filters.ZuulProperties;
import org.springframework.core.Ordered;
Expand Down Expand Up @@ -50,14 +48,13 @@ protected ZuulProperties.ZuulRoute resolveRoute(ZuulWebSocketProperties.WsBroker
}

protected URI resolveUri(ServiceInstance serviceInstance) {
Map<String, Object> metadata = new HashMap<>();
Map<String, String> metadata = new HashMap<>();
for (Map.Entry<String, String> entry : serviceInstance.getMetadata().entrySet()) {
metadata.put(entry.getKey(), entry.getValue());
metadata.put(entry.getKey().replaceAll("[-_.]", "").toLowerCase(), entry.getValue());
}

UriComponentsBuilder uriBuilder = UriComponentsBuilder.fromUri(serviceInstance.getUri());
RelaxedPropertyResolver propertyResolver = new RelaxedPropertyResolver(new MapPropertyResolver(metadata));
String configPath = propertyResolver.getProperty("configPath");
String configPath = metadata.get("configpath");
if (configPath != null) {
uriBuilder.path(configPath);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
import org.springframework.web.socket.WebSocketHandler;
import org.springframework.web.socket.client.WebSocketClient;
import org.springframework.web.socket.client.standard.StandardWebSocketClient;
import org.springframework.web.socket.config.annotation.AbstractWebSocketMessageBrokerConfigurer;
import org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer;
import org.springframework.web.socket.config.annotation.DelegatingWebSocketMessageBrokerConfiguration;
import org.springframework.web.socket.config.annotation.SockJsServiceRegistration;
import org.springframework.web.socket.config.annotation.StompEndpointRegistry;
Expand Down Expand Up @@ -82,8 +82,7 @@
@ConditionalOnProperty(prefix = "zuul.ws", name = "enabled", havingValue = "true", matchIfMissing = true)
@EnableConfigurationProperties(ZuulWebSocketProperties.class)
@AutoConfigureAfter(DelegatingWebSocketMessageBrokerConfiguration.class)
public class ZuulWebSocketConfiguration extends AbstractWebSocketMessageBrokerConfigurer
implements ApplicationListener<ContextRefreshedEvent> {
public class ZuulWebSocketConfiguration implements WebSocketMessageBrokerConfigurer, ApplicationListener<ContextRefreshedEvent> {
@Autowired
ZuulWebSocketProperties zuulWebSocketProperties;
@Autowired
Expand Down Expand Up @@ -265,8 +264,8 @@ public ProxyRedirectFilter proxyRedirectFilter(RouteLocator routeLocator) {

@PostConstruct
public void init() {
ignorePattern("**/websocket");
ignorePattern("**/info");
ignorePattern("/**/websocket");
ignorePattern("/**/info");
}

private void ignorePattern(String ignoredPattern) {
Expand Down