diff --git a/src/main/java/com/poogle/phog/web/profile/controller/ProfileController.java b/src/main/java/com/poogle/phog/web/profile/controller/ProfileController.java new file mode 100644 index 0000000..43308a3 --- /dev/null +++ b/src/main/java/com/poogle/phog/web/profile/controller/ProfileController.java @@ -0,0 +1,26 @@ +package com.poogle.phog.web.profile.controller; + +import lombok.RequiredArgsConstructor; +import org.springframework.core.env.Environment; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.Arrays; +import java.util.List; + +@RequiredArgsConstructor +@RestController +public class ProfileController { + private final Environment env; + + @GetMapping("/profile") + public String profile() { + List profiles = Arrays.asList(env.getActiveProfiles()); + List deployProfiles = Arrays.asList("deploy", "deploy1", "deploy2"); + String defaultProfile = profiles.isEmpty() ? "default" : profiles.get(0); + return profiles.stream() + .filter(deployProfiles::contains) + .findAny() + .orElse(defaultProfile); + } +}