File tree Expand file tree Collapse file tree 2 files changed +8
-10
lines changed
src/Prometheus.Client.MetricServer
tests/Prometheus.Client.MetricServer.NetCore.Tests Expand file tree Collapse file tree 2 files changed +8
-10
lines changed Original file line number Diff line number Diff line change @@ -226,23 +226,20 @@ public IServiceProvider ConfigureServices(IServiceCollection services)
226226
227227 public void Configure ( IApplicationBuilder app )
228228 {
229- app . Run ( context =>
229+ app . Map ( _mapPath , coreapp =>
230230 {
231- if ( context . Request . Path == _mapPath )
231+ coreapp . Run ( async context =>
232232 {
233233 var response = context . Response ;
234- response . ContentType = Defaults . ContentType ;
234+ response . ContentType = Defaults . ContentType ;
235235
236236 using ( var outputStream = response . Body )
237237 {
238238 ScrapeHandler . Process ( _registry , outputStream ) ;
239239 }
240240
241- return Task . FromResult ( true ) ;
242- }
243-
244- context . Response . StatusCode = 404 ;
245- return Task . FromResult ( true ) ;
241+ await Task . FromResult ( 0 ) . ConfigureAwait ( false ) ;
242+ } ) ;
246243 } ) ;
247244 }
248245 }
Original file line number Diff line number Diff line change @@ -36,15 +36,16 @@ public async Task Base_MapPath()
3636 }
3737
3838 [ Fact ]
39- public async Task MapPath_WithEndSlash_NotWorking ( )
39+ public async Task MapPath_WithEndSlash ( )
4040 {
4141 const int port = 9000 ;
4242 var metricServer = new MetricServer ( port , "/test" ) ;
4343 metricServer . Start ( ) ;
4444
4545 using ( var httpClient = new HttpClient ( ) )
4646 {
47- await Assert . ThrowsAsync < HttpRequestException > ( ( ) => httpClient . GetStringAsync ( $ "http://localhost:{ port } /test/") ) ;
47+ var response = await httpClient . GetStringAsync ( $ "http://localhost:{ port } /test/") ;
48+ Assert . False ( string . IsNullOrEmpty ( response ) ) ;
4849 }
4950
5051 metricServer . Stop ( ) ;
You can’t perform that action at this time.
0 commit comments