File tree 3 files changed +27
-1
lines changed
test/Microsoft.AspNetCore.Tests 3 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ Microsoft.AspNetCore.Builder.WebApplication.Services.get -> System.IServiceProvi
25
25
Microsoft.AspNetCore.Builder.WebApplication.StartAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task!
26
26
Microsoft.AspNetCore.Builder.WebApplication.StopAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task!
27
27
Microsoft.AspNetCore.Builder.WebApplication.Urls.get -> System.Collections.Generic.ICollection<string!>!
28
+ Microsoft.AspNetCore.Builder.WebApplication.Use(System.Func<Microsoft.AspNetCore.Http.RequestDelegate!, Microsoft.AspNetCore.Http.RequestDelegate!>! middleware) -> Microsoft.AspNetCore.Builder.IApplicationBuilder!
28
29
Microsoft.AspNetCore.Builder.WebApplicationBuilder
29
30
Microsoft.AspNetCore.Builder.WebApplicationBuilder.Build() -> Microsoft.AspNetCore.Builder.WebApplication!
30
31
Microsoft.AspNetCore.Builder.WebApplicationBuilder.Configuration.get -> Microsoft.Extensions.Configuration.ConfigurationManager!
Original file line number Diff line number Diff line change @@ -181,7 +181,12 @@ IApplicationBuilder IApplicationBuilder.New()
181
181
return newBuilder ;
182
182
}
183
183
184
- IApplicationBuilder IApplicationBuilder . Use ( Func < RequestDelegate , RequestDelegate > middleware )
184
+ /// <summary>
185
+ /// Adds the middleware to the application request pipeline.
186
+ /// </summary>
187
+ /// <param name="middleware">The middleware.</param>
188
+ /// <returns>An instance of <see cref="IApplicationBuilder"/> after the operation has completed.</returns>
189
+ public IApplicationBuilder Use ( Func < RequestDelegate , RequestDelegate > middleware )
185
190
{
186
191
ApplicationBuilder . Use ( middleware ) ;
187
192
return this ;
Original file line number Diff line number Diff line change @@ -1835,6 +1835,26 @@ public void ConfigurationProviderTypesArePreserved()
1835
1835
Assert . Single ( ( ( IConfigurationRoot ) app . Configuration ) . Providers . OfType < RandomConfigurationProvider > ( ) ) ;
1836
1836
}
1837
1837
1838
+ [ Fact ]
1839
+ public async Task CanUseMiddleware ( )
1840
+ {
1841
+ var builder = WebApplication . CreateBuilder ( ) ;
1842
+ builder . WebHost . UseTestServer ( ) ;
1843
+ await using var app = builder . Build ( ) ;
1844
+
1845
+ app . Use ( next =>
1846
+ {
1847
+ return context => context . Response . WriteAsync ( "Hello World" ) ;
1848
+ } ) ;
1849
+
1850
+ await app . StartAsync ( ) ;
1851
+
1852
+ var client = app . GetTestClient ( ) ;
1853
+
1854
+ var response = await client . GetStringAsync ( "/" ) ;
1855
+ Assert . Equal ( "Hello World" , response ) ;
1856
+ }
1857
+
1838
1858
public class RandomConfigurationSource : IConfigurationSource
1839
1859
{
1840
1860
public int ProvidersBuilt { get ; set ; }
You can’t perform that action at this time.
0 commit comments