refactor(ping-service): remove CORS configuration from code, restructure modules, and update Gradle dependencies
Migrated CORS settings from code to `application.yaml` for better separation of concerns. Integrated `ping-api` into the new `contracts` module for improved modularity. Updated Gradle scripts and dependencies accordingly to reflect the new project structure.
This commit is contained in:
@@ -7,6 +7,19 @@ spring:
|
|||||||
- org.springframework.cloud.client.loadbalancer.LoadBalancerAutoConfiguration
|
- org.springframework.cloud.client.loadbalancer.LoadBalancerAutoConfiguration
|
||||||
cloud:
|
cloud:
|
||||||
gateway:
|
gateway:
|
||||||
|
globalcors:
|
||||||
|
cors-configurations:
|
||||||
|
'[/**]':
|
||||||
|
allowed-origin-patterns: "http://localhost:*,http://127.0.0.1:*"
|
||||||
|
allowed-methods:
|
||||||
|
- GET
|
||||||
|
- POST
|
||||||
|
- PUT
|
||||||
|
- DELETE
|
||||||
|
- OPTIONS
|
||||||
|
allowed-headers: "*"
|
||||||
|
allow-credentials: true
|
||||||
|
max-age: 3600
|
||||||
httpclient:
|
httpclient:
|
||||||
connect-timeout: 3000
|
connect-timeout: 3000
|
||||||
response-timeout: 5s
|
response-timeout: 5s
|
||||||
|
|||||||
@@ -42,17 +42,6 @@ spring:
|
|||||||
health-check-interval: 10s
|
health-check-interval: 10s
|
||||||
instance-id: ${spring.application.name}-${server.port}-${random.uuid}
|
instance-id: ${spring.application.name}-${server.port}-${random.uuid}
|
||||||
|
|
||||||
# CORS-Konfiguration ausgelagert aus dem Code
|
|
||||||
web:
|
|
||||||
cors:
|
|
||||||
mappings:
|
|
||||||
"/**":
|
|
||||||
allowed-origin-patterns: "http://localhost:*,http://127.0.0.1:*"
|
|
||||||
allowed-methods: "GET,POST,PUT,DELETE,OPTIONS"
|
|
||||||
allowed-headers: "*"
|
|
||||||
allow-credentials: true
|
|
||||||
max-age: 3600
|
|
||||||
|
|
||||||
management:
|
management:
|
||||||
endpoints:
|
endpoints:
|
||||||
web:
|
web:
|
||||||
|
|||||||
@@ -17,11 +17,11 @@ wiederverwendbare Vorlage zu schaffen.
|
|||||||
|
|
||||||
1. Modulstruktur anlegen
|
1. Modulstruktur anlegen
|
||||||
|
|
||||||
Bitte lege die folgende Modulstruktur unter backend/services/ping an. Beachte die neue, klarere Benennung des
|
Bitte lege die folgende Modulstruktur an. Beachte die neue, klarere Benennung des
|
||||||
Implementierungsmoduls:
|
Implementierungsmoduls:
|
||||||
|
|
||||||
- `:backend:services:ping:ping-api`: Enthält die KMP-kompatiblen DTOs.
|
- `:contracts:ping-api`: Enthält die KMP-kompatiblen DTOs.
|
||||||
- `:backend:services:ping:ping-infrastructure`: Enthält die Spring Boot Anwendung, Controller und Konfiguration.
|
- `:backend:services:ping:ping-service`: Enthält die Spring Boot Anwendung, Controller und Konfiguration.
|
||||||
|
|
||||||
Stelle sicher, dass die Module in der `settings.gradle.kts` registriert sind.
|
Stelle sicher, dass die Module in der `settings.gradle.kts` registriert sind.
|
||||||
|
|
||||||
@@ -29,9 +29,9 @@ Stelle sicher, dass die Module in der `settings.gradle.kts` registriert sind.
|
|||||||
include(
|
include(
|
||||||
":platform:platform-bom",
|
":platform:platform-bom",
|
||||||
":platform:platform-testing",
|
":platform:platform-testing",
|
||||||
":backend:services:ping:ping-api",
|
":contracts:ping-api",
|
||||||
":backend:services:ping:ping-infrastructure",
|
":backend:services:ping:ping-service",
|
||||||
":backend:gateway",
|
":backend:infrastructure:gateway",
|
||||||
// ":backend:services:registry:registry-api",
|
// ":backend:services:registry:registry-api",
|
||||||
// ":backend:services:registry:registry-domain",
|
// ":backend:services:registry:registry-domain",
|
||||||
```
|
```
|
||||||
@@ -56,7 +56,7 @@ JVM-spezifischen Abhängigkeiten** enthalten, um die KMP-Kompatibilität für da
|
|||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
3. Service-Implementierung in :ping-infrastructure
|
3. Service-Implementierung in :ping-service
|
||||||
|
|
||||||
Implementiere die Spring Boot Anwendung.
|
Implementiere die Spring Boot Anwendung.
|
||||||
|
|
||||||
@@ -67,7 +67,7 @@ Implementiere die Spring Boot Anwendung.
|
|||||||
Hier ist ein Implementierungsvorschlag für den Controller:
|
Hier ist ein Implementierungsvorschlag für den Controller:
|
||||||
|
|
||||||
```kotlin
|
```kotlin
|
||||||
// in backend/services/ping/ping-infrastructure/src/main/kotlin/.../PingController.kt
|
// in backend/services/ping/ping-service/src/main/kotlin/.../PingController.kt
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api/ping")
|
@RequestMapping("/api/ping")
|
||||||
@@ -96,7 +96,7 @@ Erstelle die `application.yml` für den Service. Sie muss die Anwendung für uns
|
|||||||
- **Observability:** Actuator-Endpunkte (`health`, `info`, `prometheus`) freigeben und Tracing aktivieren.
|
- **Observability:** Actuator-Endpunkte (`health`, `info`, `prometheus`) freigeben und Tracing aktivieren.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
# in backend/services/ping/ping-infrastructure/src/main/resources/application.yml
|
# in backend/services/ping/ping-service/src/main/resources/application.yml
|
||||||
|
|
||||||
server:
|
server:
|
||||||
port: 8081 # Eindeutiger Port für den Service
|
port: 8081 # Eindeutiger Port für den Service
|
||||||
@@ -159,7 +159,7 @@ Achte auf die korrekte und saubere Definition der Abhängigkeiten.
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
- `ping-infrastructure/build.gradle.kts`
|
- `ping-service/build.gradle.kts`
|
||||||
```kotlin
|
```kotlin
|
||||||
plugins {
|
plugins {
|
||||||
alias(libs.plugins.spring.boot)
|
alias(libs.plugins.spring.boot)
|
||||||
@@ -169,7 +169,7 @@ Achte auf die korrekte und saubere Definition der Abhängigkeiten.
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
// API-Modul einbinden
|
// API-Modul einbinden
|
||||||
implementation(project(":backend:services:ping:ping-api"))
|
implementation(project(":contracts:ping-api"))
|
||||||
|
|
||||||
// Unsere zentrale BOM für konsistente Versionen
|
// Unsere zentrale BOM für konsistente Versionen
|
||||||
implementation(platform(project(":platform:platform-bom")))
|
implementation(platform(project(":platform:platform-bom")))
|
||||||
|
|||||||
+1
-1
@@ -12,7 +12,7 @@ pluginManagement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
plugins {
|
plugins {
|
||||||
id("org.gradle.toolchains.foojay-resolver-convention") version "1.0.0"
|
alias(libs.plugins.foojayResolver)
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencyResolutionManagement {
|
dependencyResolutionManagement {
|
||||||
|
|||||||
Reference in New Issue
Block a user