123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- using GrpcShared;
-
- using Microsoft.AspNetCore.Server.Kestrel.Core;
- using ProtoBuf.Grpc.Server;
- using Microsoft.Extensions.Options;
- using GrpcShared.DTO.Auth;
- using Blazored.LocalStorage;
- using IdentityProvider.Models;
- using IdentityProvider.Services;
-
- var builder = WebApplication.CreateBuilder(args);
- #if DEBUG
-
- //builder.WebHost.ConfigureKestrel(options =>
- //{
- // options.ListenLocalhost(5050, o => o.Protocols =
- // HttpProtocols.Http2);
- // options.ListenLocalhost(5051, o => o.Protocols =
- // HttpProtocols.Http1AndHttp2);
- //});
-
- #endif
-
- builder.Services.AddOptions();
- // Additional configuration is required to successfully run gRPC on macOS.
- // For instructions on how to configure Kestrel and gRPC clients on macOS, visit https://go.microsoft.com/fwlink/?linkid=2099682
- builder.Services.AddControllersWithViews();
- builder.Services.AddRazorPages();
-
- builder.Services.AddEndpointsApiExplorer();
-
- builder.Services.AddGrpc();
- builder.Services.AddCodeFirstGrpc();
- builder.Services.AddCodeFirstGrpcReflection();
- builder.Services.AddBlazoredLocalStorage();
- //call spotify api
- builder.Services.AddHttpClient();
-
- //builder.Services.AddSingleton<SpotifyDbConfig>();
-
- builder.Services.Configure<SpotifyDbConfig>(
- builder.Configuration.GetSection("SpotifyDb"));
-
- //builder.Services.AddHttpClient("HttpClient", c =>
- //{
- // c.BaseAddress = new Uri(builder.Configuration.GetSection("SpotifyConfig:SpotifyURL").Value.ToString());
- // c.DefaultRequestHeaders.Add("Accept", builder.Configuration.GetSection("SpotifyConfig:MediaType").Value.ToString());
-
- //});
-
- var app = builder.Build();
-
- // Configure the HTTP request pipeline.
- if (app.Environment.IsDevelopment())
- {
- app.UseWebAssemblyDebugging();
- }
- else
- {
-
- app.UseExceptionHandler("/Error");
- // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
- app.UseHsts();
- }
-
- //app.UseHttpsRedirection();
-
- //run blazor project by running grpc server
- app.UseBlazorFrameworkFiles();
- app.UseStaticFiles();
-
- app.UseRouting();
-
- //for http2 -> http conversion
- app.UseGrpcWeb();
-
- app.MapRazorPages();
- app.MapControllers();
-
- //app.MapGrpcService<WeatherService>();
- //app.MapGrpcService<AuthService>().EnableGrpcWeb();
- //app.MapGrpcService<TrackService>().EnableGrpcWeb();
- //app.MapGrpcService<StatsService>().EnableGrpcWeb();
- app.MapGrpcService<IdentityService>();
-
- app.MapCodeFirstGrpcReflectionService();
-
- app.MapFallbackToFile("index.html");
-
- app.Run("http://127.0.0.1:5002");
|