1 files changed, 20 insertions, 51 deletions
diff --git a/extra/admin-api/Spacebar.ConfigModel/Class1.cs b/extra/admin-api/Spacebar.ConfigModel/Class1.cs
index 948ca91a..26e9d0fc 100644
--- a/extra/admin-api/Spacebar.ConfigModel/Class1.cs
+++ b/extra/admin-api/Spacebar.ConfigModel/Class1.cs
@@ -2,63 +2,32 @@
namespace Spacebar.ConfigModel;
-public class Config
-{
- [JsonPropertyName("admin")] public EndpointConfig Admin { get; set; } = null!;
- [JsonPropertyName("api")] public EndpointConfig Api { get; set; } = null!;
- [JsonPropertyName("gateway")] public EndpointConfig Gateway { get; set; } = null!;
- [JsonPropertyName("cdn")] public EndpointConfig Cdn { get; set; } = null!;
+public class Config {
+ [JsonPropertyName("admin")]
+ public EndpointConfig Admin { get; set; } = null!;
- public Config ReadFromKv(Dictionary<string, object?> kv)
- {
- // to object
-
+ [JsonPropertyName("api")]
+ public EndpointConfig Api { get; set; } = null!;
- foreach (var (key, value) in kv)
- {
- switch (key.Split('_', 2)[0])
- {
- default:
- Console.WriteLine($"Unrecognized config key prefix: {key}");
- continue;
- }
- }
+ [JsonPropertyName("gateway")]
+ public EndpointConfig Gateway { get; set; } = null!;
- return this;
- }
+ [JsonPropertyName("cdn")]
+ public EndpointConfig Cdn { get; set; } = null!;
}
-public class EndpointConfig
-{
- [JsonPropertyName("endpointPrivate")] public string? EndpointPrivate { get; set; }
- [JsonPropertyName("endpointPublic")] public string? EndpointPublic { get; set; }
+public class EndpointConfig {
+ [JsonPropertyName("endpointPrivate")]
+ public string? EndpointPrivate { get; set; }
- public EndpointConfig ReadFromKv(Dictionary<string, object?> kv, string prefix)
- {
- foreach (var (key, value) in kv)
- {
- if (!key.StartsWith(prefix + "_")) continue;
- var subKey = key[(prefix + "_").Length..];
- switch (subKey)
- {
- case "ENDPOINT_PRIVATE":
- EndpointPrivate = value?.ToString();
- break;
- case "ENDPOINT_PUBLIC":
- EndpointPublic = value?.ToString();
- break;
- default:
- Console.WriteLine($"Unrecognized config key: {key}");
- break;
- }
- }
-
- return this;
- }
+ [JsonPropertyName("endpointPublic")]
+ public string? EndpointPublic { get; set; }
}
-public class ApiConfig : EndpointConfig
-{
- [JsonPropertyName("activeVersions")] public List<string> ActiveVersions { get; set; } = null!;
- [JsonPropertyName("defaultVersion")] public string DefaultVersion { get; set; } = null!;
+public class ApiConfig : EndpointConfig {
+ [JsonPropertyName("activeVersions")]
+ public List<string> ActiveVersions { get; set; } = null!;
+
+ [JsonPropertyName("defaultVersion")]
+ public string DefaultVersion { get; set; } = null!;
}
\ No newline at end of file
|