본문 바로가기
Back-End (web)

[Spring] GatewayFilterFactory add Order

by 햄과함께 2020. 7. 2.
320x100

kotlin 으로 작성되었습니다.

abstract class AbstractOrderedGatewayFilterFactory private constructor() : AbstractGatewayFilterFactory<Any>() {

    private var order: Int = 0

    constructor(order: Int) : this() {
        this.order = order
    }

    override fun apply(config: Any?): GatewayFilter {
        return OrderedGatewayFilter(GatewayFilter { exchange, chain -> chain.filter(exchange) }, order)
    }
}
@Component
class CustomGatewayFilterFactory : AbstractOrderedGatewayFilterFactory(10) {

    override fun apply(config: Any?) = GatewayFilter { exchange: ServerWebExchange, chain: GatewayFilterChain ->
        // ...
    }
}

 

참고 : https://github.com/spring-cloud/spring-cloud-gateway/issues/1122

320x100

댓글