feat: add /api/version endpoint returning build time and version
Build and Deploy Spring Boot Server / build (push) Successful in 1m25s

This commit is contained in:
2026-05-12 23:08:37 +02:00
parent a3fa59f347
commit 29f26a8a18
3 changed files with 25 additions and 0 deletions
+7
View File
@@ -128,6 +128,13 @@
</exclude> </exclude>
</excludes> </excludes>
</configuration> </configuration>
<executions>
<execution>
<goals>
<goal>build-info</goal>
</goals>
</execution>
</executions>
</plugin> </plugin>
</plugins> </plugins>
</build> </build>
@@ -1,13 +1,30 @@
package de.zendric.app.xpensely_server.controller; package de.zendric.app.xpensely_server.controller;
import org.springframework.boot.info.BuildProperties;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.Map;
@RestController @RestController
class HomeController { class HomeController {
private final BuildProperties buildProperties;
HomeController(BuildProperties buildProperties) {
this.buildProperties = buildProperties;
}
@GetMapping("/") @GetMapping("/")
public String getAll() { public String getAll() {
return "Welcome"; return "Welcome";
} }
@GetMapping("/api/version")
public Map<String, String> version() {
return Map.of(
"version", buildProperties.getVersion(),
"builtAt", buildProperties.getTime().toString()
);
}
} }
@@ -28,6 +28,7 @@ public class SecurityConfig {
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception { public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
http http
.authorizeHttpRequests(auth -> auth .authorizeHttpRequests(auth -> auth
.requestMatchers("/api/version").permitAll()
.anyRequest().authenticated()) .anyRequest().authenticated())
.oauth2ResourceServer(oauth2 -> oauth2 .oauth2ResourceServer(oauth2 -> oauth2
.jwt(Customizer.withDefaults())) .jwt(Customizer.withDefaults()))