-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add current state of demo application
- Loading branch information
1 parent
723b284
commit f429c0a
Showing
28 changed files
with
653 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile | ||
|
||
plugins { | ||
id("org.springframework.boot") version "2.1.6.RELEASE" | ||
id("io.spring.dependency-management") version "1.0.7.RELEASE" | ||
kotlin("jvm") version "1.3.41" | ||
kotlin("plugin.spring") version "1.3.41" | ||
} | ||
|
||
group = "de.tobiasgies" | ||
version = "0.0.1-SNAPSHOT" | ||
java.sourceCompatibility = JavaVersion.VERSION_11 | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
extra["springCloudVersion"] = "Greenwich.SR2" | ||
|
||
dependencies { | ||
implementation("org.jetbrains.kotlin:kotlin-reflect") | ||
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8") | ||
implementation("org.springframework.cloud:spring-cloud-starter-gateway") | ||
testImplementation("org.springframework.boot:spring-boot-starter-test") | ||
} | ||
|
||
dependencyManagement { | ||
imports { | ||
mavenBom("org.springframework.cloud:spring-cloud-dependencies:${property("springCloudVersion")}") | ||
} | ||
} | ||
|
||
tasks.withType<KotlinCompile> { | ||
kotlinOptions { | ||
freeCompilerArgs = listOf("-Xjsr305=strict") | ||
jvmTarget = "1.8" | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
apigateway/src/main/kotlin/de/tobiasgies/apigateway/ApigatewayApplication.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package de.tobiasgies.apigateway | ||
|
||
import org.springframework.boot.autoconfigure.SpringBootApplication | ||
import org.springframework.boot.runApplication | ||
|
||
@SpringBootApplication | ||
class ApigatewayApplication | ||
|
||
fun main(args: Array<String>) { | ||
runApplication<ApigatewayApplication>(*args) | ||
} |
13 changes: 13 additions & 0 deletions
13
apigateway/src/main/kotlin/de/tobiasgies/apigateway/LocalEndpoints.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package de.tobiasgies.apigateway | ||
|
||
import org.springframework.web.bind.annotation.GetMapping | ||
import org.springframework.web.bind.annotation.RequestMapping | ||
import org.springframework.web.bind.annotation.RestController | ||
import reactor.core.publisher.Mono | ||
|
||
@RequestMapping("/local_endpoints") | ||
@RestController | ||
class LocalEndpoints { | ||
@GetMapping("/go_away") | ||
fun goAway() = Mono.just("Go away, Apple has no place in this household!") | ||
} |
30 changes: 30 additions & 0 deletions
30
apigateway/src/main/kotlin/de/tobiasgies/apigateway/RoutingConfiguration.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package de.tobiasgies.apigateway | ||
|
||
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder | ||
import org.springframework.cloud.gateway.route.builder.routes | ||
import org.springframework.context.annotation.Bean | ||
import org.springframework.context.annotation.Configuration | ||
|
||
@Configuration | ||
class RoutingConfiguration { | ||
@Bean | ||
fun routingDefinition(builder: RouteLocatorBuilder) = builder.routes { | ||
route(id = "bouquet_microservice", order = 1) { | ||
path("/bouquet/*") | ||
uri("http://localhost:8091") | ||
} | ||
route(id = "business_microservice", order = 2) { | ||
path("/business/*") | ||
uri("http://localhost:8092") | ||
} | ||
route(id = "inventory_microservice", order = 3) { | ||
path("/inventory/*") | ||
uri("http://localhost:8093") | ||
} | ||
route(id = "catchall", order = 10) { | ||
alwaysTrue() | ||
uri("forward:/local_endpoints/go_away") | ||
} | ||
} | ||
} | ||
|
26 changes: 26 additions & 0 deletions
26
apigateway/src/main/kotlin/de/tobiasgies/apigateway/SampleGlobalFilter.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package de.tobiasgies.apigateway | ||
|
||
import org.springframework.cloud.gateway.filter.GatewayFilterChain | ||
import org.springframework.cloud.gateway.filter.GlobalFilter | ||
import org.springframework.stereotype.Component | ||
import org.springframework.web.server.ServerWebExchange | ||
import reactor.core.publisher.Mono | ||
|
||
/** | ||
* Filters are available in per-route and global versions. | ||
* | ||
* [@Components][Component] that implement [GlobalFilter] are automatically added to the global filter chain. Their | ||
* order of execution can be influenced using [@Ordered][org.springframework.core.Ordered]. | ||
* | ||
* BEWARE: Filtering happens after routing. You cannot influence routing decisions in any way using filters. That's what | ||
* [Route Predicates][java.util.function.Predicate] are for. | ||
*/ | ||
@Component | ||
class SampleGlobalFilter : GlobalFilter { | ||
override fun filter(exchange: ServerWebExchange?, chain: GatewayFilterChain): Mono<Void> { | ||
// Do something interesting with the request, e.g. manipulate the exchange. | ||
// Afterwards, pass the request on to the next filter in the chain: | ||
return chain.filter(exchange) | ||
} | ||
|
||
} |
21 changes: 21 additions & 0 deletions
21
apigateway/src/main/kotlin/de/tobiasgies/apigateway/SampleWebServerCustomizer.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package de.tobiasgies.apigateway | ||
|
||
import org.springframework.boot.web.embedded.netty.NettyReactiveWebServerFactory | ||
import org.springframework.boot.web.server.WebServerFactoryCustomizer | ||
import org.springframework.stereotype.Component | ||
|
||
/** | ||
* Customize the underlying Netty web server. | ||
* | ||
* If the factory itself does not expose a customization option, it is possible to manipulate the | ||
* [reactor.netty.http.server.HttpServer] directly by using [NettyReactiveWebServerFactory.addServerCustomizers]. | ||
*/ | ||
@Component | ||
class SampleWebServerCustomizer : | ||
WebServerFactoryCustomizer<NettyReactiveWebServerFactory> { | ||
override fun customize(factory: NettyReactiveWebServerFactory) { | ||
// For example: customize TLS settings here | ||
// factory.ssl = Ssl() | ||
// side note: One could use netty-tcnative and its OpenSSL bindings as well. | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
server: | ||
port: 8080 |
16 changes: 16 additions & 0 deletions
16
apigateway/src/test/kotlin/de/tobiasgies/apigateway/ApigatewayApplicationTests.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package de.tobiasgies.apigateway | ||
|
||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import org.springframework.boot.test.context.SpringBootTest | ||
import org.springframework.test.context.junit4.SpringRunner | ||
|
||
@RunWith(SpringRunner::class) | ||
@SpringBootTest | ||
class ApigatewayApplicationTests { | ||
|
||
@Test | ||
fun contextLoads() { | ||
} | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile | ||
|
||
plugins { | ||
id("org.springframework.boot") version "2.1.6.RELEASE" | ||
id("io.spring.dependency-management") version "1.0.7.RELEASE" | ||
kotlin("jvm") version "1.3.41" | ||
kotlin("plugin.spring") version "1.3.41" | ||
} | ||
|
||
group = "de.tobiasgies" | ||
version = "0.0.1-SNAPSHOT" | ||
java.sourceCompatibility = JavaVersion.VERSION_11 | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
implementation("org.springframework.boot:spring-boot-starter-webflux") | ||
implementation("com.fasterxml.jackson.module:jackson-module-kotlin") | ||
implementation("org.jetbrains.kotlin:kotlin-reflect") | ||
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8") | ||
testImplementation("org.springframework.boot:spring-boot-starter-test") | ||
testImplementation("io.projectreactor:reactor-test") | ||
} | ||
|
||
tasks.withType<KotlinCompile> { | ||
kotlinOptions { | ||
freeCompilerArgs = listOf("-Xjsr305=strict") | ||
jvmTarget = "1.8" | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
bouquet/src/main/kotlin/de/tobiasgies/bouquet/BouquetApplication.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package de.tobiasgies.bouquet | ||
|
||
import org.springframework.boot.autoconfigure.SpringBootApplication | ||
import org.springframework.boot.runApplication | ||
|
||
@SpringBootApplication | ||
class BouquetApplication | ||
|
||
fun main(args: Array<String>) { | ||
runApplication<BouquetApplication>(*args) | ||
} |
13 changes: 13 additions & 0 deletions
13
bouquet/src/main/kotlin/de/tobiasgies/bouquet/BouquetController.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package de.tobiasgies.bouquet | ||
|
||
import org.springframework.web.bind.annotation.GetMapping | ||
import org.springframework.web.bind.annotation.RequestMapping | ||
import org.springframework.web.bind.annotation.RestController | ||
import reactor.core.publisher.Mono | ||
|
||
@RestController | ||
@RequestMapping("/bouquet") | ||
class BouquetController { | ||
@GetMapping("/hello") | ||
fun hello() = Mono.just("Hello from the bouquet controller!") | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
server: | ||
port: 8091 |
16 changes: 16 additions & 0 deletions
16
bouquet/src/test/kotlin/de/tobiasgies/bouquet/BouquetApplicationTests.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package de.tobiasgies.bouquet | ||
|
||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import org.springframework.boot.test.context.SpringBootTest | ||
import org.springframework.test.context.junit4.SpringRunner | ||
|
||
@RunWith(SpringRunner::class) | ||
@SpringBootTest | ||
class BouquetApplicationTests { | ||
|
||
@Test | ||
fun contextLoads() { | ||
} | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile | ||
|
||
plugins { | ||
id("org.springframework.boot") version "2.1.6.RELEASE" | ||
id("io.spring.dependency-management") version "1.0.7.RELEASE" | ||
kotlin("jvm") version "1.3.41" | ||
kotlin("plugin.spring") version "1.3.41" | ||
} | ||
|
||
group = "de.tobiasgies" | ||
version = "0.0.1-SNAPSHOT" | ||
java.sourceCompatibility = JavaVersion.VERSION_11 | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
implementation("org.springframework.boot:spring-boot-starter-webflux") | ||
implementation("com.fasterxml.jackson.module:jackson-module-kotlin") | ||
implementation("org.jetbrains.kotlin:kotlin-reflect") | ||
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8") | ||
testImplementation("org.springframework.boot:spring-boot-starter-test") | ||
testImplementation("io.projectreactor:reactor-test") | ||
} | ||
|
||
tasks.withType<KotlinCompile> { | ||
kotlinOptions { | ||
freeCompilerArgs = listOf("-Xjsr305=strict") | ||
jvmTarget = "1.8" | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
business/src/main/kotlin/de/tobiasgies/business/BusinessApplication.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package de.tobiasgies.business | ||
|
||
import org.springframework.boot.autoconfigure.SpringBootApplication | ||
import org.springframework.boot.runApplication | ||
|
||
@SpringBootApplication | ||
class BusinessApplication | ||
|
||
fun main(args: Array<String>) { | ||
runApplication<BusinessApplication>(*args) | ||
} |
13 changes: 13 additions & 0 deletions
13
business/src/main/kotlin/de/tobiasgies/business/BusinessController.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package de.tobiasgies.business | ||
|
||
import org.springframework.web.bind.annotation.GetMapping | ||
import org.springframework.web.bind.annotation.RequestMapping | ||
import org.springframework.web.bind.annotation.RestController | ||
import reactor.core.publisher.Mono | ||
|
||
@RestController | ||
@RequestMapping("/business") | ||
class BusinessController { | ||
@GetMapping("/hello") | ||
fun hello() = Mono.just("Hello from the business controller!") | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
server: | ||
port: 8092 |
16 changes: 16 additions & 0 deletions
16
business/src/test/kotlin/de/tobiasgies/business/BusinessApplicationTests.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package de.tobiasgies.business | ||
|
||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import org.springframework.boot.test.context.SpringBootTest | ||
import org.springframework.test.context.junit4.SpringRunner | ||
|
||
@RunWith(SpringRunner::class) | ||
@SpringBootTest | ||
class BusinessApplicationTests { | ||
|
||
@Test | ||
fun contextLoads() { | ||
} | ||
|
||
} |
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-bin.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
Oops, something went wrong.