Skip to content

Commit

Permalink
feat: Add GetMapping profile to ProfileController
Browse files Browse the repository at this point in the history
- Get all the active profiles and check if there's a profile for deploy.

Issue #38
  • Loading branch information
suhyunsim committed Dec 29, 2020
1 parent 968de93 commit 754c347
Showing 1 changed file with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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<String> profiles = Arrays.asList(env.getActiveProfiles());
List<String> deployProfiles = Arrays.asList("deploy", "deploy1", "deploy2");
String defaultProfile = profiles.isEmpty() ? "default" : profiles.get(0);
return profiles.stream()
.filter(deployProfiles::contains)
.findAny()
.orElse(defaultProfile);
}
}

0 comments on commit 754c347

Please sign in to comment.