Created
March 27, 2020 12:05
-
-
Save artemptushkin/48111d49b84e16e5f2f43cf5c65d6b3b to your computer and use it in GitHub Desktop.
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 io.github.aptushkin.proxy.image.filter | |
import org.springframework.cloud.gateway.filter.GatewayFilter | |
import org.springframework.cloud.gateway.filter.GatewayFilterChain | |
import org.springframework.cloud.gateway.filter.RouteToRequestUrlFilter.ROUTE_TO_URL_FILTER_ORDER | |
import org.springframework.cloud.gateway.support.ServerWebExchangeUtils | |
import org.springframework.core.Ordered | |
import org.springframework.web.server.ServerWebExchange | |
import reactor.core.publisher.Mono | |
class ProxyForwardGatewayFilter: GatewayFilter, Ordered { | |
override fun getOrder(): Int = ROUTE_TO_URL_FILTER_ORDER + 1 | |
override fun filter(exchange: ServerWebExchange, chain: GatewayFilterChain): Mono<Void> { | |
val target = exchange.request.uri | |
exchange.attributes[ServerWebExchangeUtils.GATEWAY_REQUEST_URL_ATTR] = target | |
return chain.filter(exchange) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment