Skip to content

Commit

Permalink
Merge pull request #13 from Moyeothon-NewTeams/feature/develop
Browse files Browse the repository at this point in the history
🔀Style: develop -> main
  • Loading branch information
eunxeum authored Oct 31, 2024
2 parents 42285b4 + 43b306a commit 4ceaff3
Showing 1 changed file with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.example.moyeothon.Controller;

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;

@RestController
public class ProfileController {

private final Environment env;

public ProfileController(Environment env) {
this.env = env;
}

@GetMapping("/profile")
public String profile() {
List<String> profiles = Arrays.asList(env.getActiveProfiles());
List<String> realProfiles = Arrays.asList("real1", "real2");
String defaultProfile = profiles.isEmpty() ? "default" : profiles.get(0);

return profiles.stream()
.filter(realProfiles::contains)
.findAny()
.orElse(defaultProfile);
}
}

0 comments on commit 4ceaff3

Please sign in to comment.