Cédric Michel
4 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with
20 additions and
17 deletions
-
src/BlazorAdmin/Program.cs
-
src/BlazorAdmin/Services/CatalogLookupDataService.cs
-
src/BlazorAdmin/Services/HttpService.cs
-
src/PublicApi/Startup.cs
-
src/Web/HealthChecks/ApiHealthCheck.cs
-
src/Web/Startup.cs
|
|
|
@ -1,4 +1,4 @@ |
|
|
|
using System; |
|
|
|
using System; |
|
|
|
using System.Net.Http; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using BlazorAdmin.Services; |
|
|
|
@ -20,9 +20,8 @@ public class Program |
|
|
|
var builder = WebAssemblyHostBuilder.CreateDefault(args); |
|
|
|
builder.RootComponents.Add<App>("#admin"); |
|
|
|
|
|
|
|
var baseUrlConfig = new BaseUrlConfiguration(); |
|
|
|
builder.Configuration.Bind(BaseUrlConfiguration.CONFIG_NAME, baseUrlConfig); |
|
|
|
builder.Services.AddScoped<BaseUrlConfiguration>(sp => baseUrlConfig); |
|
|
|
var configSection = builder.Configuration.GetRequiredSection(BaseUrlConfiguration.CONFIG_NAME); |
|
|
|
builder.Services.Configure<BaseUrlConfiguration>(configSection); |
|
|
|
|
|
|
|
builder.Services.AddScoped(sp => new HttpClient() { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); |
|
|
|
|
|
|
|
@ -37,7 +36,7 @@ public class Program |
|
|
|
|
|
|
|
builder.Services.AddBlazorServices(); |
|
|
|
|
|
|
|
builder.Logging.AddConfiguration(builder.Configuration.GetSection("Logging")); |
|
|
|
builder.Logging.AddConfiguration(builder.Configuration.GetRequiredSection("Logging")); |
|
|
|
|
|
|
|
await ClearLocalStorageCache(builder.Services); |
|
|
|
|
|
|
|
|
|
|
|
@ -9,6 +9,7 @@ using BlazorShared.Attributes; |
|
|
|
using BlazorShared.Interfaces; |
|
|
|
using BlazorShared.Models; |
|
|
|
using Microsoft.Extensions.Logging; |
|
|
|
using Microsoft.Extensions.Options; |
|
|
|
|
|
|
|
namespace BlazorAdmin.Services; |
|
|
|
|
|
|
|
@ -23,12 +24,12 @@ public class CatalogLookupDataService<TLookupData, TReponse> |
|
|
|
private readonly string _apiUrl; |
|
|
|
|
|
|
|
public CatalogLookupDataService(HttpClient httpClient, |
|
|
|
BaseUrlConfiguration baseUrlConfiguration, |
|
|
|
IOptions<BaseUrlConfiguration> baseUrlConfiguration, |
|
|
|
ILogger<CatalogLookupDataService<TLookupData, TReponse>> logger) |
|
|
|
{ |
|
|
|
_httpClient = httpClient; |
|
|
|
_logger = logger; |
|
|
|
_apiUrl = baseUrlConfiguration.ApiBase; |
|
|
|
_apiUrl = baseUrlConfiguration.Value.ApiBase; |
|
|
|
} |
|
|
|
|
|
|
|
public async Task<List<TLookupData>> List() |
|
|
|
|
|
|
|
@ -4,6 +4,7 @@ using System.Text.Json; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using BlazorShared; |
|
|
|
using BlazorShared.Models; |
|
|
|
using Microsoft.Extensions.Options; |
|
|
|
|
|
|
|
namespace BlazorAdmin.Services; |
|
|
|
|
|
|
|
@ -14,11 +15,11 @@ public class HttpService |
|
|
|
private readonly string _apiUrl; |
|
|
|
|
|
|
|
|
|
|
|
public HttpService(HttpClient httpClient, BaseUrlConfiguration baseUrlConfiguration, ToastService toastService) |
|
|
|
public HttpService(HttpClient httpClient, IOptions<BaseUrlConfiguration> baseUrlConfiguration, ToastService toastService) |
|
|
|
{ |
|
|
|
_httpClient = httpClient; |
|
|
|
_toastService = toastService; |
|
|
|
_apiUrl = baseUrlConfiguration.ApiBase; |
|
|
|
_apiUrl = baseUrlConfiguration.Value.ApiBase; |
|
|
|
} |
|
|
|
|
|
|
|
public async Task<T> HttpGet<T>(string uri) |
|
|
|
|
|
|
|
@ -1,4 +1,4 @@ |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Text; |
|
|
|
using AutoMapper; |
|
|
|
using BlazorShared; |
|
|
|
@ -96,8 +96,9 @@ public class Startup |
|
|
|
services.AddScoped(typeof(IAppLogger<>), typeof(LoggerAdapter<>)); |
|
|
|
services.AddScoped<ITokenClaimsService, IdentityTokenClaimService>(); |
|
|
|
|
|
|
|
var baseUrlConfig = new BaseUrlConfiguration(); |
|
|
|
Configuration.Bind(BaseUrlConfiguration.CONFIG_NAME, baseUrlConfig); |
|
|
|
var configSection = Configuration.GetRequiredSection(BaseUrlConfiguration.CONFIG_NAME); |
|
|
|
services.Configure<BaseUrlConfiguration>(configSection); |
|
|
|
var baseUrlConfig = configSection.Get<BaseUrlConfiguration>(); |
|
|
|
|
|
|
|
services.AddMemoryCache(); |
|
|
|
|
|
|
|
|
|
|
|
@ -3,6 +3,7 @@ using System.Threading; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using BlazorShared; |
|
|
|
using Microsoft.Extensions.Diagnostics.HealthChecks; |
|
|
|
using Microsoft.Extensions.Options; |
|
|
|
|
|
|
|
namespace Microsoft.eShopWeb.Web.HealthChecks; |
|
|
|
|
|
|
|
@ -10,9 +11,9 @@ public class ApiHealthCheck : IHealthCheck |
|
|
|
{ |
|
|
|
private readonly BaseUrlConfiguration _baseUrlConfiguration; |
|
|
|
|
|
|
|
public ApiHealthCheck(BaseUrlConfiguration baseUrlConfiguration) |
|
|
|
public ApiHealthCheck(IOptions<BaseUrlConfiguration> baseUrlConfiguration) |
|
|
|
{ |
|
|
|
_baseUrlConfiguration = baseUrlConfiguration; |
|
|
|
_baseUrlConfiguration = baseUrlConfiguration.Value; |
|
|
|
} |
|
|
|
|
|
|
|
public async Task<HealthCheckResult> CheckHealthAsync( |
|
|
|
|
|
|
|
@ -148,10 +148,10 @@ public class Startup |
|
|
|
config.Path = "/allservices"; |
|
|
|
}); |
|
|
|
|
|
|
|
var configSection = Configuration.GetRequiredSection(BaseUrlConfiguration.CONFIG_NAME); |
|
|
|
services.Configure<BaseUrlConfiguration>(configSection); |
|
|
|
var baseUrlConfig = configSection.Get<BaseUrlConfiguration>(); |
|
|
|
|
|
|
|
var baseUrlConfig = new BaseUrlConfiguration(); |
|
|
|
Configuration.Bind(BaseUrlConfiguration.CONFIG_NAME, baseUrlConfig); |
|
|
|
services.AddScoped<BaseUrlConfiguration>(sp => baseUrlConfig); |
|
|
|
// Blazor Admin Required Services for Prerendering
|
|
|
|
services.AddScoped<HttpClient>(s => new HttpClient |
|
|
|
{ |
|
|
|
|