msa : msa - api gateway

This commit is contained in:
haerong22
2021-08-02 16:33:09 +09:00
parent e02d823f36
commit 5e8f7ad59f
5 changed files with 97 additions and 1 deletions

View File

@@ -0,0 +1,52 @@
plugins {
id 'org.springframework.boot' version '2.4.4'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'java'
}
group 'org.example'
version '1.0-SNAPSHOT'
sourceCompatibility = "1.11"
ext {
springCloudSleuthOtelVersion = "1.0.0-M1"
releaseTrainVersion = "2020.0.1"
}
apply plugin: "io.spring.dependency-management"
repositories {
mavenCentral()
maven {
url "https://repo.spring.io/snapshot"
}
maven {
url "https://repo.spring.io/milestone"
}
maven {
url "https://repo.spring.io/release"
}
}
// MSA 용
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${releaseTrainVersion}"
mavenBom "org.springframework.cloud:spring-cloud-sleuth-otel-dependencies:${springCloudSleuthOtelVersion}"
}
}
dependencies {
compile("org.springframework.cloud:spring-cloud-starter-config")
compile("org.springframework.cloud:spring-cloud-starter-netflix-eureka-client")
compile("org.springframework.cloud:spring-cloud-starter-gateway")
implementation 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
}
test {
useJUnitPlatform()
}

View File

@@ -0,0 +1,11 @@
package com.msatest.gateway;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class GatewayDemoApplication {
public static void main(String[] args) {
SpringApplication.run(GatewayDemoApplication.class,args);
}
}

View File

@@ -0,0 +1,27 @@
server:
port: 8080
spring:
application:
name: eureka-server
cloud:
gateway:
routes:
- id: user-api
uri: http://localhost:8091
predicates:
- Path=/user/**
# 미완
- id: payment-api
uri: http://localhost:8090
predicates:
- Path=/payment/**
- id: webbook-api
uri: http://localhost:8092
predicates:
- Path=/webbook/**
eureka:
client:
register-with-eureka: false
fetch-registry: false

View File

@@ -2,4 +2,5 @@ rootProject.name = 'msatest'
include 'userdemo'
include 'paymentdemo'
include 'webbookdemo'
include 'gatewaydemo'

View File

@@ -14,13 +14,18 @@ import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping("/reader")
@RequestMapping("/user/reader")
@RequiredArgsConstructor
public class ReaderController {
private final ReaderService ReaderService;
private final ReaderWebBookService readerWebBookService;
@GetMapping("/hello")
public ResponseEntity<String> getHello() {
return ResponseEntity.ok().body("Hello");
}
@PostMapping("/")
public ResponseEntity<Long> registerReader(@RequestBody RegisterReaderForm registerReaderForm){
return ResponseEntity.ok(ReaderService.registerReader(registerReaderForm));