|
23 | 23 | import io.mapsmessaging.configuration.ConfigurationProperties;
|
24 | 24 | import io.mapsmessaging.dto.rest.config.BaseConfigDTO;
|
25 | 25 | import io.mapsmessaging.dto.rest.config.RestApiManagerConfigDTO;
|
| 26 | +import io.mapsmessaging.rest.handler.CorsHeaderManager; |
26 | 27 | import io.mapsmessaging.utilities.configuration.ConfigurationManager;
|
27 | 28 | import java.io.IOException;
|
| 29 | +import java.util.HashMap; |
| 30 | +import java.util.Map; |
28 | 31 | import lombok.NoArgsConstructor;
|
29 | 32 |
|
30 | 33 | @NoArgsConstructor
|
@@ -63,6 +66,16 @@ private RestApiManagerConfig(ConfigurationProperties properties) {
|
63 | 66 | if (properties.containsKey("static")) {
|
64 | 67 | this.staticConfig = new StaticConfig((ConfigurationProperties) properties.get("static"));
|
65 | 68 | }
|
| 69 | + |
| 70 | + corsHeaders = CorsHeaderManager.getInstance().getCorsHeaders(); |
| 71 | + if(properties.containsKey("corsHeaders")) { |
| 72 | + Map<String, Object> corsHeadersProp = ((ConfigurationProperties) properties.get("corsHeaders")).getMap(); |
| 73 | + for(Map.Entry<String, Object> entry : corsHeadersProp.entrySet()) { |
| 74 | + String key = entry.getKey(); |
| 75 | + String value = entry.getValue().toString(); |
| 76 | + corsHeaders.addHeader(key, value); |
| 77 | + } |
| 78 | + } |
66 | 79 | }
|
67 | 80 |
|
68 | 81 | @Override
|
@@ -146,7 +159,8 @@ public ConfigurationProperties toConfigurationProperties() {
|
146 | 159 | if (this.staticConfig != null) {
|
147 | 160 | properties.put("static", this.staticConfig.toConfigurationProperties());
|
148 | 161 | }
|
149 |
| - |
| 162 | + Map<String, Object> corsHeadersProp = new HashMap<>(CorsHeaderManager.getInstance().getCorsHeaders().getHeaders()); |
| 163 | + properties.put("corsHeaders", corsHeadersProp); |
150 | 164 | return properties;
|
151 | 165 | }
|
152 | 166 |
|
|
0 commit comments