Skip to content

Commit

Permalink
[#156] 환경변수에서도 application.properties 값을 추출
Browse files Browse the repository at this point in the history
  • Loading branch information
myyrakle committed Oct 9, 2024
1 parent e601028 commit 9774030
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions rupring/src/application_properties.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ impl ApplicationProperties {

let mut key_values = HashMap::new();

// application.properties 파일에서 추출
for line in text.lines() {
let mut parts = line.split("=");

Expand All @@ -149,6 +150,17 @@ impl ApplicationProperties {
key_values.insert(key, value);
}

// 환경변수에서도 추출
let env = std::env::vars().collect::<HashMap<_, _>>();
for (key, value) in env {
if key_values.contains_key(&key) {
continue;
}

key_values.insert(key, value);
}

// 추출한 key-value를 바탕으로 기본 정의된 항목은 바인딩, 그 외는 etc에 저장
for (key, value) in key_values {
// TODO: 매크로 기반 파싱 구현
match key.as_str() {
Expand Down

0 comments on commit 9774030

Please sign in to comment.