From 6d3bd858dd08538905ea311c6f7e40cb3811fcce Mon Sep 17 00:00:00 2001 From: napoly Date: Sat, 27 Jan 2024 19:45:38 +0100 Subject: [PATCH] Add API version to api/version end-point --- src/main/java/haveno/price/ApiController.java | 23 +++++++++++++++++++ src/main/resources/application.properties | 1 + 2 files changed, 24 insertions(+) create mode 100644 src/main/java/haveno/price/ApiController.java diff --git a/src/main/java/haveno/price/ApiController.java b/src/main/java/haveno/price/ApiController.java new file mode 100644 index 0000000..cb42d9d --- /dev/null +++ b/src/main/java/haveno/price/ApiController.java @@ -0,0 +1,23 @@ +package haveno.price; + +import java.util.HashMap; +import java.util.Map; + +import lombok.RequiredArgsConstructor; +import org.springframework.core.env.Environment; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequiredArgsConstructor +public class ApiController { + + private final Environment env; + + @GetMapping("/api/version") + public Map getVersion() { + Map response = new HashMap<>(); + response.put("version", env.getProperty("haveno.price-node.api.version", "")); + return response; + } +} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 67421c6..2129b88 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,3 +1,4 @@ +haveno.price-node.api.version=1.0.0 server.port=8078 spring.jackson.serialization.indent_output=true