This commit is contained in:
parent
3c521fcba8
commit
f7764b21d9
@ -21,6 +21,8 @@ dependencies {
|
||||
implementation("org.jetbrains.kotlin:kotlin-reflect")
|
||||
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
|
||||
implementation("org.springframework.cloud:spring-cloud-starter-gateway")
|
||||
implementation("org.springframework.cloud:spring-cloud-starter-netflix-hystrix")
|
||||
implementation("org.springframework.boot:spring-boot-starter-actuator")
|
||||
testImplementation("org.springframework.boot:spring-boot-starter-test") {
|
||||
exclude(group = "org.junit.vintage", module = "junit-vintage-engine")
|
||||
}
|
||||
|
@ -0,0 +1,97 @@
|
||||
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()
|
||||
}
|
||||
}
|
13
src/main/resources/application.yml
Normal file
13
src/main/resources/application.yml
Normal file
@ -0,0 +1,13 @@
|
||||
management:
|
||||
endpoints:
|
||||
web:
|
||||
exposure:
|
||||
include: hystrix.stream
|
||||
|
||||
hystrix:
|
||||
command:
|
||||
fallbackcmd:
|
||||
execution:
|
||||
isolation:
|
||||
thread:
|
||||
timeoutInMilliseconds: 3000
|
Loading…
Reference in New Issue
Block a user