From 2bed5f9818e0672d3f36a1419f6d093689435ada 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 --- .github/workflows/build.yml | 1 - src/main/java/haveno/price/ApiController.java | 23 +++++++++++++++++++ src/main/resources/application.properties | 1 + 3 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 src/main/java/haveno/price/ApiController.java diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 61a014c..bc8413f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,7 +14,6 @@ jobs: uses: actions/checkout@v3 with: submodules: recursive - token: ${{ secrets.PAT_TOKEN }} - name: Set up JDK 11 uses: actions/setup-java@v3 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