Skip to content

Commit e8c40b1

Browse files
committed
internal startup convert into primary constructor
1 parent 9a01123 commit e8c40b1

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

src/MetricServer.cs

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -71,33 +71,26 @@ public void Stop()
7171
_host = null;
7272
}
7373

74-
internal class Startup : IStartup
74+
internal class Startup(MetricServerOptions options) : IStartup
7575
{
76-
private readonly MetricServerOptions _options;
77-
78-
public Startup(MetricServerOptions options)
79-
{
80-
_options = options;
81-
}
82-
8376
public IServiceProvider ConfigureServices(IServiceCollection services)
8477
{
8578
return services.BuildServiceProvider();
8679
}
8780

8881
public void Configure(IApplicationBuilder app)
8982
{
90-
var contentType = _options.ResponseEncoding != null
91-
? $"{Defaults.ContentType}; charset={_options.ResponseEncoding.BodyName}"
83+
var contentType = options.ResponseEncoding != null
84+
? $"{Defaults.ContentType}; charset={options.ResponseEncoding.BodyName}"
9285
: Defaults.ContentType;
93-
app.Map(_options.MapPath, coreapp =>
86+
app.Map(options.MapPath, coreapp =>
9487
{
9588
coreapp.Run(async context =>
9689
{
9790
var response = context.Response;
9891
response.ContentType = contentType;
9992
await using var outputStream = response.Body;
100-
await ScrapeHandler.ProcessAsync(_options.CollectorRegistry, outputStream);
93+
await ScrapeHandler.ProcessAsync(options.CollectorRegistry, outputStream);
10194
});
10295
});
10396
}

0 commit comments

Comments
 (0)