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 символів.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. using GrpcShared;
  2. using Microsoft.AspNetCore.Server.Kestrel.Core;
  3. using ProtoBuf.Grpc.Server;
  4. using Microsoft.Extensions.Options;
  5. using GrpcShared.DTO.Auth;
  6. using IdentityProvider.Models;
  7. using IdentityProvider.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.AddOptions();
  19. // Additional configuration is required to successfully run gRPC on macOS.
  20. // For instructions on how to configure Kestrel and gRPC clients on macOS, visit https://go.microsoft.com/fwlink/?linkid=2099682
  21. builder.Services.AddControllersWithViews();
  22. builder.Services.AddRazorPages();
  23. builder.Services.AddEndpointsApiExplorer();
  24. builder.Services.AddGrpc();
  25. builder.Services.AddCodeFirstGrpc();
  26. builder.Services.AddCodeFirstGrpcReflection();
  27. //call spotify api
  28. builder.Services.AddHttpClient();
  29. //builder.Services.AddSingleton<SpotifyDbConfig>();
  30. builder.Services.Configure<SpotifyDbConfig>(
  31. builder.Configuration.GetSection("SpotifyDb"));
  32. //builder.Services.AddHttpClient("HttpClient", c =>
  33. //{
  34. // c.BaseAddress = new Uri(builder.Configuration.GetSection("SpotifyConfig:SpotifyURL").Value.ToString());
  35. // c.DefaultRequestHeaders.Add("Accept", builder.Configuration.GetSection("SpotifyConfig:MediaType").Value.ToString());
  36. //});
  37. var app = builder.Build();
  38. // Configure the HTTP request pipeline.
  39. if (app.Environment.IsDevelopment())
  40. {
  41. app.UseWebAssemblyDebugging();
  42. }
  43. else
  44. {
  45. app.UseExceptionHandler("/Error");
  46. // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
  47. app.UseHsts();
  48. }
  49. //app.UseHttpsRedirection();
  50. //run blazor project by running grpc server
  51. app.UseBlazorFrameworkFiles();
  52. app.UseStaticFiles();
  53. app.UseRouting();
  54. //for http2 -> http conversion
  55. app.UseGrpcWeb();
  56. app.MapRazorPages();
  57. app.MapControllers();
  58. //app.MapGrpcService<WeatherService>();
  59. //app.MapGrpcService<AuthService>().EnableGrpcWeb();
  60. //app.MapGrpcService<TrackService>().EnableGrpcWeb();
  61. //app.MapGrpcService<StatsService>().EnableGrpcWeb();
  62. app.MapGrpcService<IdentityService>();
  63. app.MapCodeFirstGrpcReflectionService();
  64. app.MapFallbackToFile("index.html");
  65. app.Run("http://127.0.0.1:5002");