File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33#if NET6_0
44
55using System ;
6+ using System . Net . Http ;
67using Microsoft . AspNetCore . Builder ;
78using Microsoft . AspNetCore . CookiePolicy ;
89using Microsoft . AspNetCore . Hosting ;
910using Microsoft . AspNetCore . Http ;
1011using Microsoft . Extensions . DependencyInjection ;
1112using Microsoft . Extensions . Hosting ;
13+ using ServiceStack . Host ;
1214
1315namespace ServiceStack
1416{
@@ -99,6 +101,14 @@ private static bool DisallowsSameSiteNone(string userAgent)
99101
100102 return false ;
101103 }
104+
105+ public static IHttpClientBuilder AddHttpUtilsClient ( this IServiceCollection services )
106+ {
107+ HostContext . ConfigureAppHost ( appHost => HttpUtils . CreateClient = ( ) =>
108+ appHost . TryResolve < IHttpClientFactory > ( ) . CreateClient ( nameof ( HttpUtils ) ) ) ;
109+ return services . AddHttpClient ( nameof ( HttpUtils ) ) ;
110+ }
111+
102112 }
103113}
104114
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ namespace MyApp
1414 public class AppHost : AppHostBase , IHostingStartup
1515 {
1616 public void Configure ( IWebHostBuilder builder ) => builder
17+ . ConfigureServices ( services => services . AddHttpUtilsClient ( ) )
1718 . Configure ( app => {
1819 if ( ! HasInit )
1920 app . UseServiceStack ( new AppHost ( ) ) ;
You can’t perform that action at this time.
0 commit comments