Inject an HTTP client into the DI system

This commit is contained in:
Thorsten Sommer 2024-06-02 20:51:26 +02:00
parent 5a528357a4
commit 58160f3eaa
Signed by: tsommer
GPG Key ID: 371BBA77A02C0108

View File

@ -10,6 +10,7 @@ using System.Reflection;
using Microsoft.Extensions.FileProviders; using Microsoft.Extensions.FileProviders;
#endif #endif
var port = args.Length > 0 ? args[0] : "5000";
var builder = WebApplication.CreateBuilder(); var builder = WebApplication.CreateBuilder();
builder.Services.AddMudServices(config => builder.Services.AddMudServices(config =>
{ {
@ -37,7 +38,11 @@ builder.Services.AddRazorComponents()
options.HandshakeTimeout = TimeSpan.FromSeconds(30); options.HandshakeTimeout = TimeSpan.FromSeconds(30);
}); });
var port = args.Length > 0 ? args[0] : "5000"; builder.Services.AddSingleton(new HttpClient
{
BaseAddress = new Uri($"http://localhost:{port}")
});
builder.WebHost.UseUrls($"http://localhost:{port}"); builder.WebHost.UseUrls($"http://localhost:{port}");
#if DEBUG #if DEBUG