Skip to content

Instantly share code, notes, and snippets.

@AdrianoJS
Last active April 12, 2023 18:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AdrianoJS/2cfc2268320434daf2be83196a69afb2 to your computer and use it in GitHub Desktop.
Save AdrianoJS/2cfc2268320434daf2be83196a69afb2 to your computer and use it in GitHub Desktop.
spring-cloud-gateway-example-BarController
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