msa : msa - api gateway
This commit is contained in:
52
msa_practice/msatest/gatewaydemo/build.gradle
Normal file
52
msa_practice/msatest/gatewaydemo/build.gradle
Normal 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()
|
||||||
|
}
|
||||||
@@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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
|
||||||
@@ -2,4 +2,5 @@ rootProject.name = 'msatest'
|
|||||||
include 'userdemo'
|
include 'userdemo'
|
||||||
include 'paymentdemo'
|
include 'paymentdemo'
|
||||||
include 'webbookdemo'
|
include 'webbookdemo'
|
||||||
|
include 'gatewaydemo'
|
||||||
|
|
||||||
|
|||||||
@@ -14,13 +14,18 @@ import org.springframework.web.bind.annotation.*;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/reader")
|
@RequestMapping("/user/reader")
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class ReaderController {
|
public class ReaderController {
|
||||||
|
|
||||||
private final ReaderService ReaderService;
|
private final ReaderService ReaderService;
|
||||||
private final ReaderWebBookService readerWebBookService;
|
private final ReaderWebBookService readerWebBookService;
|
||||||
|
|
||||||
|
@GetMapping("/hello")
|
||||||
|
public ResponseEntity<String> getHello() {
|
||||||
|
return ResponseEntity.ok().body("Hello");
|
||||||
|
}
|
||||||
|
|
||||||
@PostMapping("/")
|
@PostMapping("/")
|
||||||
public ResponseEntity<Long> registerReader(@RequestBody RegisterReaderForm registerReaderForm){
|
public ResponseEntity<Long> registerReader(@RequestBody RegisterReaderForm registerReaderForm){
|
||||||
return ResponseEntity.ok(ReaderService.registerReader(registerReaderForm));
|
return ResponseEntity.ok(ReaderService.registerReader(registerReaderForm));
|
||||||
|
|||||||
Reference in New Issue
Block a user