From e93f970706c2db63b7585bb083d94331b9db9fed Mon Sep 17 00:00:00 2001 From: John Colvin Date: Sun, 14 Jul 2024 13:16:50 -0400 Subject: [PATCH] SparkApiService check pt --- src/client/spark_api/Services/SparkApiConfig.cs | 11 ----------- src/client/spark_api/Services/SparkApiServices.cs | 5 +++++ 2 files changed, 5 insertions(+), 11 deletions(-) delete mode 100644 src/client/spark_api/Services/SparkApiConfig.cs diff --git a/src/client/spark_api/Services/SparkApiConfig.cs b/src/client/spark_api/Services/SparkApiConfig.cs deleted file mode 100644 index f58c7c47e..000000000 --- a/src/client/spark_api/Services/SparkApiConfig.cs +++ /dev/null @@ -1,11 +0,0 @@ -#nullable enable -namespace Spark.Api.Services; - -public class SparkApiConfig { - public string? ConfigServer { get; set; } - public string? User { get; set; } - public string? Password { get; set; } - public bool EnableAdmin { get; set; } - public bool EnableOrders { get; set; } - public bool EnablePosition { get; set; } -} diff --git a/src/client/spark_api/Services/SparkApiServices.cs b/src/client/spark_api/Services/SparkApiServices.cs index ed7674769..c10ba1830 100644 --- a/src/client/spark_api/Services/SparkApiServices.cs +++ b/src/client/spark_api/Services/SparkApiServices.cs @@ -25,6 +25,11 @@ public static class SparkApiServices { /// The to add the service to. /// A reference to this instance after the operation has completed. public static IServiceCollection AddSparkApi(this IServiceCollection services, IConfiguration configurationSection) { + if (!configurationSection.GetValue("IsEnabled", true)) { + // Make it obvious we aren't connecting to Sparkd. + Console.WriteLine("SparkApi services have been disabled"); + return services; + } if (!services.Any(s => s.ServiceType == typeof(SparkService))) { /// initializes configuration and logging (this should be done /// before any api-related services run).