/// <summary> /// Called by the runtime. /// </summary> /// <param name="services">Injected services.</param> public void ConfigureServices(IServiceCollection services) { services.AddControllers().AddJsonOptions(options => { options.JsonSerializerOptions.DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull; options.JsonSerializerOptions.PropertyNameCaseInsensitive = true; }); services.AddTransient <ICommandExecutor, CommandExecutor>(); services.AddAllActuators(); services.ActivateActuatorEndpoints(); services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new OpenApiInfo { Title = "Steeltoe.NetCoreToolService", Version = "v0" }); }); }
/// <summary> /// Called by the runtime. Adds <see cref="IUiConfigService"/> and <see cref="IProjectGenerator"/> services. /// </summary> /// <param name="services">Injected services.</param> public void ConfigureServices(IServiceCollection services) { services.AddOptions(); services.Configure <InitializrServiceOptions>(Configuration.GetSection(InitializrServiceOptions.InitializrService)); InitializrServiceOptions options; try { options = Configuration.GetSection(InitializrServiceOptions.InitializrService).Get <InitializrServiceOptions>(); } catch (Exception e) { if (e.InnerException is KeyNotFoundException) { throw new ArgumentException("InitializrService configuration is missing or errant"); } throw; } _netCoreToolServiceUri = options?.NetCoreToolServiceUri; if (options?.UiConfigPath is null) { services.ConfigureConfigServerClientOptions(); services.Configure <UiConfig>(Configuration); services.AddTransient <IUiConfigService, UiConfigService>(); } else { services.AddTransient <IUiConfigService, UiConfigFile>(); } services.AddResponseCompression(); services.AddTransient <IProjectGenerator, NetCoreToolProjectGenerator>(); services.AddAllActuators(); services.ActivateActuatorEndpoints(); services.AddGoogleAnalyticsTracker(trackerOptions => { trackerOptions.TrackerId = "UA-114912118-2"; }); services.AddControllers().AddJsonOptions(jsonOptions => { jsonOptions.JsonSerializerOptions.DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull; jsonOptions.JsonSerializerOptions.PropertyNameCaseInsensitive = true; }); }