Last active
April 12, 2023 18:38
-
-
Save AdrianoJS/2cfc2268320434daf2be83196a69afb2 to your computer and use it in GitHub Desktop.
spring-cloud-gateway-example-BarController
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package no.embriq.bar; | |
import org.springframework.http.MediaType; | |
import org.springframework.web.bind.annotation.GetMapping; | |
import org.springframework.web.bind.annotation.RequestMapping; | |
import org.springframework.web.bind.annotation.RequestParam; | |
import org.springframework.web.bind.annotation.RestController; | |
import reactor.core.publisher.Mono; | |
@RestController | |
@RequestMapping( | |
path = "/api", | |
produces = MediaType.APPLICATION_JSON_VALUE | |
) | |
public class BarController { | |
@GetMapping("/ping") | |
public Mono<PingResponse> ping() { | |
return Mono.just(new PingResponse(Status.UP, "bar")); | |
} | |
@GetMapping("/subtract") | |
public Mono<SubtractionResponse> subtract(@RequestParam int a, @RequestParam int b) { | |
return Mono.just(new SubtractionResponse(a - b)); | |
} | |
enum Status { | |
UP, DOWN | |
} | |
record SubtractionResponse(int result) { | |
} | |
record PingResponse(Status status, String applicationName) { | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment