Add ApiOptions and configure API settings
Added a new `ApiOptions` class to encapsulate API configuration, including the `BaseUrl` property and `SectionName` constant. Registered `ApiOptions` in the dependency injection container in `Program.cs` and bound it to the "Api" section in the configuration file. Updated `appsettings.json` to include the "Api" section with a `BaseUrl` value of "https://localhost:8088".
This commit is contained in:
8
EnvelopeGenerator.ReceiverUI/Options/ApiOptions.cs
Normal file
8
EnvelopeGenerator.ReceiverUI/Options/ApiOptions.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace EnvelopeGenerator.ReceiverUI.Options;
|
||||
|
||||
public class ApiOptions
|
||||
{
|
||||
public const string SectionName = "Api";
|
||||
|
||||
public string BaseUrl { get; set; } = string.Empty;
|
||||
}
|
||||
@@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Components.Web;
|
||||
using EnvelopeGenerator.ReceiverUI;
|
||||
using DevExpress.DataAccess.Web;
|
||||
using EnvelopeGenerator.ReceiverUI.Services;
|
||||
using EnvelopeGenerator.ReceiverUI.Options;
|
||||
using DevExpress.XtraReports.Services;
|
||||
using DevExpress.Blazor.Reporting;
|
||||
using DevExpress.XtraReports.Web.Extensions;
|
||||
@@ -11,6 +12,8 @@ var builder = WebAssemblyHostBuilder.CreateDefault(args);
|
||||
builder.RootComponents.Add<App>("#app");
|
||||
builder.RootComponents.Add<HeadOutlet>("head::after");
|
||||
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });
|
||||
builder.Services.Configure<ApiOptions>(opts =>
|
||||
builder.Configuration.GetSection(ApiOptions.SectionName).Bind(opts));
|
||||
builder.Services.AddScoped<EnvelopeGenerator.ReceiverUI.Services.DocumentService>();
|
||||
|
||||
builder.Services.AddDevExpressWebAssemblyBlazorReportViewer();
|
||||
|
||||
5
EnvelopeGenerator.ReceiverUI/wwwroot/appsettings.json
Normal file
5
EnvelopeGenerator.ReceiverUI/wwwroot/appsettings.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"Api": {
|
||||
"BaseUrl": "https://localhost:8088"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user