Я сгенерировал следующее. Во-первых, служба, которая возвращает жестко закодированную строку:
Код: Выделить всё
package com.test.serviceplay.controller;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/api/play")
public class PlayController {
@GetMapping("/{id}")
public ResponseEntity playGet(@PathVariable Long id){
return ResponseEntity.ok("Play GET called");
}
}
Код: Выделить всё
org.springframework.boot
spring-boot-starter-webmvc
org.springframework.boot
spring-boot-starter-webmvc-test
test
фрагмент pom.xml:
Код: Выделить всё
org.springframework.cloud
spring-cloud-starter-gateway-server-webflux
org.springframework.boot
spring-boot-starter-test
test
io.projectreactor
reactor-test
test
Код: Выделить всё
spring:
application:
name: gateway-play
cloud:
gateway:
routes:
- id: service-play
uri: http://localhost:8080
predicates:
- Path=/api/play/**
server:
port: 9191
Код: Выделить всё
http://localhost:8080/api/play/1Код: Выделить всё
http://localhost:9191/api/play/1Будем очень благодарны за любую помощь.
Подробнее здесь: https://stackoverflow.com/questions/798 ... ve-gateway
Мобильная версия