Created
May 16, 2019 16:20
-
-
Save dylanberry/8cf04c591ebf81f46a197855316012fe to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using HttpTracer; | |
using System.Net.Http; | |
using Microsoft.AspNetCore.Components.Browser; | |
using Microsoft.AspNetCore.Components.Builder; | |
using Microsoft.Extensions.DependencyInjection; | |
using Microsoft.AspNetCore.Components; | |
using System; | |
using Microsoft.AspNetCore.Blazor.Services; | |
using Microsoft.AspNetCore.Blazor.Http; | |
namespace WebApplication1 | |
{ | |
public class Startup | |
{ | |
public void ConfigureServices(IServiceCollection services) | |
{ | |
services.AddSingleton<HttpClient>(s => | |
{ | |
// Creating the URI helper needs to wait until the JS Runtime is initialized, so defer it. | |
var uriHelper = s.GetRequiredService<IUriHelper>(); | |
return new HttpClient(new HttpTracerHandler(new WebAssemblyHttpMessageHandler())) | |
{ | |
BaseAddress = new Uri(WebAssemblyUriHelper.Instance.GetBaseUri()) | |
}; | |
}); | |
} | |
public void Configure(IComponentsApplicationBuilder app) | |
{ | |
app.AddComponent<App>("app"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment