Created
April 12, 2023 18:38
-
-
Save AdrianoJS/1376c2a6df07318acf9b9c384bf6dd98 to your computer and use it in GitHub Desktop.
spring-cloud-gateway-example-FooController
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.foo; | |
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 FooController { | |
@GetMapping("/ping") | |
public Mono<PingResponse> ping() { | |
return Mono.just(new PingResponse(Status.UP, "foo")); | |
} | |
@GetMapping("/add") | |
public Mono<AdditionResponse> add(@RequestParam int a, @RequestParam int b) { | |
return Mono.just(new AdditionResponse(a + b)); | |
} | |
enum Status { | |
UP, DOWN | |
} | |
record AdditionResponse(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