Inject an HTTP client into the DI system

This commit is contained in:
tsommer committed 2024-06-02 20:51:26 +02:00
1 parent 5a528357a4
commit 58160f3eaa
1 file changed
+6 -1
+6 -1
View File
@@ -10,6 +10,7 @@ using System.Reflection;
using Microsoft.Extensions.FileProviders;
#endif
var port = args.Length > 0 ? args[0] : "5000";
var builder = WebApplication.CreateBuilder();
builder.Services.AddMudServices(config =>
{
@@ -37,7 +38,11 @@ builder.Services.AddRazorComponents()
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}");
#if DEBUG