|
|
@@ -1,14 +1,29 @@
|
|
|
package com.mokasz.image_pool.restful.controller;
|
|
|
|
|
|
+import com.mokasz.image_pool.restful.entity.IndexResponse;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
+import java.net.InetAddress;
|
|
|
+import java.net.UnknownHostException;
|
|
|
+
|
|
|
@RestController
|
|
|
@RequiredArgsConstructor
|
|
|
public class IndexController {
|
|
|
+ @Value("${pom.version}")
|
|
|
+ private String version;
|
|
|
+
|
|
|
+ private String getHostname () {
|
|
|
+ try {
|
|
|
+ return InetAddress.getLocalHost().getHostName();
|
|
|
+ } catch (UnknownHostException e) {
|
|
|
+ return "x";
|
|
|
+ }
|
|
|
+ }
|
|
|
@GetMapping("/")
|
|
|
- public String index() {
|
|
|
- return "version:1.0.0";
|
|
|
+ public IndexResponse index() {
|
|
|
+ return new IndexResponse(version, getHostname());
|
|
|
}
|
|
|
}
|