Blazor & WASM in combination to get statistics from Spotify API for performing the song analysis. With separate microservices for auth, Spotify, user data tracking, and application, connected through gRPC with Polly.
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

Program.cs 908B

123456789101112131415161718192021222324
  1. using Grpc.Net.Client;
  2. using Grpc.Net.Client.Web;
  3. using Microsoft.AspNetCore.Components;
  4. using Microsoft.AspNetCore.Components.Web;
  5. using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
  6. using NemAnBlazor;
  7. using SpotifyService.Protos;
  8. var builder = WebAssemblyHostBuilder.CreateDefault(args);
  9. builder.RootComponents.Add<App>("#app");
  10. builder.RootComponents.Add<HeadOutlet>("head::after");
  11. builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });
  12. builder.Services.AddSingleton(services =>
  13. {
  14. var httpClient = new HttpClient(new GrpcWebHandler(GrpcWebMode.GrpcWeb, new HttpClientHandler()));
  15. var baseUri = services.GetRequiredService<NavigationManager>().BaseUri;
  16. var channel = GrpcChannel.ForAddress(baseUri, new GrpcChannelOptions { HttpClient = httpClient });
  17. return new Search.SearchClient(channel);
  18. });
  19. await builder.Build().RunAsync();