| 79 | |
| 80 | impl RouterConfig { |
| 81 | pub fn load_from_file(path: &Path) -> Result<Self, RouterError> { |
| 82 | let content = std::fs::read_to_string(path).map_err(|e| { |
| 83 | RouterError::Internal(format!( |
| 84 | "failed to read router config {}: {e}", |
| 85 | path.display() |
| 86 | )) |
| 87 | })?; |
| 88 | let config: Self = serde_yml::from_str(&content).map_err(|e| { |
| 89 | RouterError::Internal(format!( |
| 90 | "failed to parse router config {}: {e}", |
| 91 | path.display() |
| 92 | )) |
| 93 | })?; |
| 94 | config.resolve() |
| 95 | } |
| 96 | |
| 97 | fn resolve(self) -> Result<Self, RouterError> { |
| 98 | // Validate that all routes can resolve their API keys |