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.
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

Program.cs 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. using GrpcShared;
  2. using IdentityProvider.Services;
  3. using Microsoft.AspNetCore.Server.Kestrel.Core;
  4. using ProtoBuf.Grpc.Server;
  5. using Microsoft.Extensions.Options;
  6. using GrpcShared.DTO.Auth;
  7. using SpotifyService.Services;
  8. var builder = WebApplication.CreateBuilder(args);
  9. #if DEBUG
  10. builder.WebHost.ConfigureKestrel(options =>
  11. {
  12. options.ListenLocalhost(5050, o => o.Protocols =
  13. HttpProtocols.Http2);
  14. options.ListenLocalhost(5051, o => o.Protocols =
  15. HttpProtocols.Http1AndHttp2);
  16. });
  17. #endif
  18. builder.Services.AddHttpClient("HttpClient", c =>
  19. {
  20. c.BaseAddress = new Uri(SpotifyService.GLOBALS.SPOTIFYURL);
  21. c.DefaultRequestHeaders.Add("Accept", SpotifyService.GLOBALS.MEDIATYPE);
  22. });
  23. builder.Services.AddOptions();
  24. // Additional configuration is required to successfully run gRPC on macOS.
  25. // For instructions on how to configure Kestrel and gRPC clients on macOS, visit https://go.microsoft.com/fwlink/?linkid=2099682
  26. builder.Services.Configure<CodeRequest>(builder.Configuration.GetSection("AuthParams"));
  27. builder.Services.AddControllersWithViews();
  28. builder.Services.AddRazorPages();
  29. builder.Services.AddEndpointsApiExplorer();
  30. builder.Services.AddGrpc();
  31. builder.Services.AddCodeFirstGrpc();
  32. builder.Services.AddCodeFirstGrpcReflection();
  33. //call spotify api
  34. builder.Services.AddHttpClient();
  35. var app = builder.Build();
  36. // Configure the HTTP request pipeline.
  37. if (app.Environment.IsDevelopment())
  38. {
  39. app.UseWebAssemblyDebugging();
  40. }
  41. else
  42. {
  43. app.UseExceptionHandler("/Error");
  44. // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
  45. app.UseHsts();
  46. }
  47. app.UseHttpsRedirection();
  48. //run blazor project by running grpc server
  49. app.UseBlazorFrameworkFiles();
  50. app.UseStaticFiles();
  51. app.UseRouting();
  52. //for http2 -> http conversion
  53. app.UseGrpcWeb();
  54. app.MapRazorPages();
  55. app.MapControllers();
  56. //app.MapGrpcService<WeatherService>();
  57. app.MapGrpcService<AuthService>().EnableGrpcWeb();
  58. app.MapGrpcService<TrackService>().EnableGrpcWeb();
  59. app.MapCodeFirstGrpcReflectionService();
  60. app.MapFallbackToFile("index.html");
  61. app.Run();