Merge branch 'ileler-master'
This commit is contained in:
@@ -114,7 +114,9 @@ public class Route implements Ordered {
|
||||
|
||||
public B uri(URI uri) {
|
||||
this.uri = uri;
|
||||
if (this.uri.getPort() < 0 && this.uri.getScheme().startsWith("http")) {
|
||||
String scheme = this.uri.getScheme();
|
||||
Assert.hasText(scheme, "The parameter [" + this.uri + "] format is incorrect, scheme can not be empty");
|
||||
if (this.uri.getPort() < 0 && scheme.startsWith("http")) {
|
||||
// default known http ports
|
||||
int port = this.uri.getScheme().equals("https") ? 443 : 80;
|
||||
this.uri = UriComponentsBuilder.fromUri(this.uri)
|
||||
|
||||
@@ -17,12 +17,17 @@
|
||||
|
||||
package org.springframework.cloud.gateway.route;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class RouteTests {
|
||||
|
||||
@Rule
|
||||
public ExpectedException exception = ExpectedException.none();
|
||||
|
||||
@Test
|
||||
public void defeaultHttpPort() {
|
||||
Route route = Route.async().id("1")
|
||||
@@ -47,7 +52,6 @@ public class RouteTests {
|
||||
.hasPort(443);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void fullUri() {
|
||||
Route route = Route.async().id("1")
|
||||
@@ -59,4 +63,12 @@ public class RouteTests {
|
||||
.hasScheme("http")
|
||||
.hasPort(8080);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nullScheme() {
|
||||
exception.expect(IllegalArgumentException.class);
|
||||
Route.async().id("1")
|
||||
.predicate(exchange -> true)
|
||||
.uri("/pathonly");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user