SparkApiService check pt

This commit is contained in:
John Colvin committed 2024-09-18 14:02:36 +00:00
1 parent 844677dae0
commit e93f970706
2 files changed
+5 -11

No files matched your search

@@ -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; }
}
@@ -25,6 +25,11 @@ public static class SparkApiServices {
/// <param name="services">The <see cref="IServiceCollection"/> to add the service to.</param>
/// <returns>A reference to this instance after the operation has completed.</returns>
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))) {
/// <see cref="SparkService"/> initializes configuration and logging (this should be done
/// before any api-related services run).