forked from thinktecture/Thinktecture.Blazor
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathProgram.cs
37 lines (27 loc) · 1.11 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using PatrickJahr.Blazor.GrpcDevTools.Client;
using Grpc.Net.Client;
using Grpc.Net.Client.Web;
using MudBlazor.Services;
using PatrickJahr.Blazor.GrpcDevTools.Shared.Services;
using PatrickJahr.Blazor.GrpcWeb.DevTools;
var builder = WebAssemblyHostBuilder.CreateDefault(args);
var backendUrl = builder.Configuration["Api:BackendUrl"] ?? builder.HostEnvironment.BaseAddress;
builder.RootComponents.Add<App>("#app");
builder.RootComponents.Add<HeadOutlet>("head::after");
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(backendUrl) });
builder.Services.AddScoped(services =>
{
var channel = GrpcChannel.ForAddress(backendUrl,
new GrpcChannelOptions
{
HttpHandler = new GrpcWebHandler(GrpcWebMode.GrpcWeb, new HttpClientHandler())
});
return channel;
});
builder.Services.AddGrpcService<IConferencesService>();
builder.Services.AddGrpcService<ITimeService>();
builder.Services.AddMudServices();
var app = builder.Build();
await app.RunAsync();