Implemented update functionallity
All checks were successful
Updater CI/CD / publish (push) Successful in 2m18s
All checks were successful
Updater CI/CD / publish (push) Successful in 2m18s
This commit is contained in:
26
Program.cs
Normal file
26
Program.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using ServiceUpdater;
|
||||
|
||||
var builder = WebApplication.CreateSlimBuilder(args);
|
||||
|
||||
// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi
|
||||
builder.Services.AddOpenApi();
|
||||
|
||||
builder.Services.AddSingleton<UpdaterConfig>();
|
||||
builder.Services.AddScoped<UpdateWorker>();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
if (app.Environment.IsDevelopment()) {
|
||||
app.MapOpenApi();
|
||||
}
|
||||
|
||||
app.MapGet("update/{service}", async (UpdateWorker worker, string service, HttpContext context) => {
|
||||
context.Response.Headers.Append("Content-Type", "text/event-stream");
|
||||
|
||||
await foreach (var line in worker.UpdateService(service)) {
|
||||
await context.Response.WriteAsync(line + '\n');
|
||||
await context.Response.Body.FlushAsync();
|
||||
}
|
||||
});
|
||||
|
||||
app.Run();
|
||||
Reference in New Issue
Block a user