97 lines
4.6 KiB
Kotlin
97 lines
4.6 KiB
Kotlin
|
package com.kmlabz.birbnetes.apigateway
|
||
|
|
||
|
import org.springframework.cloud.gateway.route.RouteLocator
|
||
|
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder
|
||
|
import org.springframework.cloud.netflix.hystrix.EnableHystrix
|
||
|
import org.springframework.context.annotation.Bean
|
||
|
import org.springframework.context.annotation.Configuration
|
||
|
|
||
|
@EnableHystrix
|
||
|
@Configuration
|
||
|
class ApiGatewayConfig {
|
||
|
@Bean
|
||
|
fun myRoutes(builder: RouteLocatorBuilder): RouteLocator {
|
||
|
return builder.routes()
|
||
|
.route { p -> p
|
||
|
.path("/api/input/v1/sample")
|
||
|
.filters { f -> f
|
||
|
.hystrix { config ->
|
||
|
config.name = "input-service-sample"
|
||
|
}
|
||
|
.rewritePath("/api/input/v1/sample", "/sample")
|
||
|
}
|
||
|
.uri("http://input-service")
|
||
|
}
|
||
|
.route { p -> p
|
||
|
.path("/api/input/v1/sample/**")
|
||
|
.filters { f -> f
|
||
|
.hystrix { config ->
|
||
|
config.name = "input-service-query"
|
||
|
}
|
||
|
.rewritePath("/api/input/v1/sample/(?<SAMPLEID>.*)", "/sample/\${SAMPLEID}")
|
||
|
}
|
||
|
.uri("http://input-service")
|
||
|
}
|
||
|
.route { p -> p
|
||
|
.path("/api/output/v1/result")
|
||
|
.filters { f -> f
|
||
|
.hystrix { config ->
|
||
|
config.name = "output-service-result"
|
||
|
}
|
||
|
.rewritePath("//api/output/v1/result", "/result")
|
||
|
}
|
||
|
.uri("http://output-service-rdb")
|
||
|
}
|
||
|
.route { p -> p
|
||
|
.path("/api/output/v1/result/**")
|
||
|
.filters { f -> f
|
||
|
.hystrix { config ->
|
||
|
config.name = "output-service-query"
|
||
|
}
|
||
|
.rewritePath("/api/output/v1/result/(?<RESULTID>.*)", "/result/\${RESULTID}")
|
||
|
}
|
||
|
.uri("http://output-service-rdb")
|
||
|
}
|
||
|
.route { p -> p
|
||
|
.path("/api/output/v1/result/filter/negative")
|
||
|
.filters { f -> f
|
||
|
.hystrix { config ->
|
||
|
config.name = "output-service-negative"
|
||
|
}
|
||
|
.rewritePath("/api/output/v1/result/filter/negative", "/result/filter/negative")
|
||
|
}
|
||
|
.uri("http://output-service-rdb")
|
||
|
}
|
||
|
.route { p -> p
|
||
|
.path("/api/output/v1/result/filter/positive")
|
||
|
.filters { f -> f
|
||
|
.hystrix { config ->
|
||
|
config.name = "output-service-positive"
|
||
|
}
|
||
|
.rewritePath("/api/output/v1/result/filter/positive", "/result/filter/positive")
|
||
|
}
|
||
|
.uri("http://output-service-rdb")
|
||
|
}
|
||
|
.route { p -> p
|
||
|
.path("/api/output/v1/result/after/**")
|
||
|
.filters { f -> f
|
||
|
.hystrix { config ->
|
||
|
config.name = "output-service-after"
|
||
|
}
|
||
|
.rewritePath("/api/output/v1/result/after/(?<DATEAFTER>.*)", "/result/after/\${DATEAFTER}")
|
||
|
}
|
||
|
.uri("http://output-service-rdb")
|
||
|
}
|
||
|
.route { p -> p
|
||
|
.path("/api/output/v1/result/before/**")
|
||
|
.filters { f -> f
|
||
|
.hystrix { config ->
|
||
|
config.name = "output-service-before"
|
||
|
}
|
||
|
.rewritePath("/api/output/v1/result/before/(?<DATEBEFORE>.*)", "/result/before/\${DATEBEFORE}")
|
||
|
}
|
||
|
.uri("http://output-service-rdb")
|
||
|
}
|
||
|
.build()
|
||
|
}
|
||
|
}
|