Ich habe Folgendes generiert. Erstens einen Dienst, der eine fest codierte Zeichenfolge zurückgibt:
Code: Select all
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");
}
}
Code: Select all
org.springframework.boot
spring-boot-starter-webmvc
org.springframework.boot
spring-boot-starter-webmvc-test
test
pom.xml-Snippet:
Code: Select all
org.springframework.cloud
spring-cloud-starter-gateway-server-webflux
org.springframework.boot
spring-boot-starter-test
test
io.projectreactor
reactor-test
test
Code: Select all
spring:
application:
name: gateway-play
cloud:
gateway:
routes:
- id: service-play
uri: http://localhost:8080
predicates:
- Path=/api/play/**
server:
port: 9191
Code: Select all
http://localhost:8080/api/play/1Code: Select all
http://localhost:9191/api/play/1Jede Hilfe wäre sehr dankbar.
Mobile version