Last active
April 21, 2021 06:25
-
-
Save xinyii/0c4d6f6d8776b75ac1431841475b851d to your computer and use it in GitHub Desktop.
[Spring Cloud Gateway] #spring
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<dependency> | |
<groupId>org.springframework.cloud</groupId> | |
<artifactId>spring-cloud-starter-gateway</artifactId> | |
</dependency> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Bean | |
public RouteLocator customRouteLocator(RouteLocatorBuilder builder) { | |
return builder.routes() | |
.route("path_route", r -> r.method(HttpMethod.GET).and().path("/mock/**") | |
.filters(f -> f.rewritePath("/mock/(?<segment>.*)", "/${segment}")) | |
.uri("https://6000221fcb21e10017af883f.mockapi.io/api/v1")) | |
.build(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment