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
.route(r -> r.path("/addThenSubtract") | |
.filters(f -> f.filter(addAndSubtractCompositionFilter.apply(new Object()))) | |
.uri(NOOP)) |
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
package no.embriq.api.gateway.filter; | |
import org.springframework.context.annotation.Bean; | |
import org.springframework.context.annotation.Configuration; | |
import org.springframework.web.reactive.function.server.RouterFunction; | |
import org.springframework.web.reactive.function.server.RouterFunctions; | |
import org.springframework.web.reactive.function.server.ServerResponse; | |
import static org.springframework.web.reactive.function.server.RequestPredicates.GET; |
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
package no.embriq.api.gateway.filter; | |
import com.fasterxml.jackson.databind.JsonNode; | |
import org.slf4j.Logger; | |
import org.slf4j.LoggerFactory; | |
import org.springframework.beans.factory.annotation.Value; | |
import org.springframework.cloud.gateway.filter.GatewayFilter; | |
import org.springframework.cloud.gateway.filter.factory.AbstractGatewayFilterFactory; | |
import org.springframework.core.io.buffer.DataBuffer; | |
import org.springframework.http.HttpStatusCode; |
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
.route(r -> r.path("/ping") | |
.filters(f -> f.filter(pingFilter.apply(new Object()))) // pingFilter.apply parameter cannot be null even though it is ignored. Throws NPE | |
.uri("https://mandatory.url.that.is.ignored.due.to.filter.logic")) |
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
package no.embriq.api.gateway.filter; | |
import org.springframework.cloud.gateway.filter.GatewayFilter; | |
import org.springframework.cloud.gateway.filter.factory.AbstractGatewayFilterFactory; | |
import org.springframework.http.HttpStatusCode; | |
import org.springframework.stereotype.Component; | |
import reactor.core.publisher.Flux; | |
import static java.nio.charset.StandardCharsets.UTF_8; |
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
package no.embriq.api.gateway.filter; | |
import org.slf4j.Logger; | |
import org.slf4j.LoggerFactory; | |
import org.springframework.cloud.gateway.filter.GatewayFilterChain; | |
import org.springframework.cloud.gateway.filter.GlobalFilter; | |
import org.springframework.core.Ordered; | |
import org.springframework.stereotype.Component; | |
import org.springframework.web.server.ServerWebExchange; | |
import reactor.core.publisher.Mono; |
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
package no.embriq.api.gateway; | |
import org.springframework.beans.factory.annotation.Autowired; | |
import org.springframework.beans.factory.annotation.Value; | |
import org.springframework.cloud.gateway.route.Route; | |
import org.springframework.cloud.gateway.route.RouteLocator; | |
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder; | |
import org.springframework.stereotype.Component; | |
import reactor.core.publisher.Flux; |
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
name | required | description | |
---|---|---|---|
id | no | Human identifier for the route | |
uri | yes | The base URL for the receiving service. Does not need or use the path part of a url as this is retrieved from the request. | |
predicates | yes | Defines what requests trigger this route. In the above examples, routes are identified by path, but can also be selected based on time, cookies, headers etc. | |
filters | no | Optional modification of input and output |
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
server: | |
port: 8080 | |
app: | |
dependencies: | |
foo: | |
baseUrl: http://localhost:8081 | |
bar: | |
baseUrl: http://localhost:8082 |
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
package no.embriq.api.gateway; | |
import org.springframework.boot.SpringApplication; | |
import org.springframework.boot.autoconfigure.SpringBootApplication; | |
@SpringBootApplication(scanBasePackages = "no.embriq.api.gateway") | |
public class GatewayApplication { | |
public static void main(String[] args) { | |
SpringApplication.run(GatewayApplication.class, args); |
NewerOlder