feat: add /api/version endpoint returning build time and version
Build and Deploy Spring Boot Server / build (push) Successful in 1m25s
Build and Deploy Spring Boot Server / build (push) Successful in 1m25s
This commit is contained in:
@@ -128,6 +128,13 @@
|
||||
</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>build-info</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
@@ -1,13 +1,30 @@
|
||||
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.RestController;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
class HomeController {
|
||||
|
||||
private final BuildProperties buildProperties;
|
||||
|
||||
HomeController(BuildProperties buildProperties) {
|
||||
this.buildProperties = buildProperties;
|
||||
}
|
||||
|
||||
@GetMapping("/")
|
||||
public String getAll() {
|
||||
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 {
|
||||
http
|
||||
.authorizeHttpRequests(auth -> auth
|
||||
.requestMatchers("/api/version").permitAll()
|
||||
.anyRequest().authenticated())
|
||||
.oauth2ResourceServer(oauth2 -> oauth2
|
||||
.jwt(Customizer.withDefaults()))
|
||||
|
||||
Reference in New Issue
Block a user