Add InstallScriptBuilder + GET /install.sh + GET /client.tar.gz
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
||||
namespace backend.Install;
|
||||
|
||||
public static class InstallEndpoints
|
||||
{
|
||||
public static IEndpointRouteBuilder MapInstallEndpoints(this IEndpointRouteBuilder app)
|
||||
{
|
||||
app.MapGet("/install.sh", (HttpContext http, InstallScriptBuilder builder) =>
|
||||
{
|
||||
var scheme = http.Request.Scheme;
|
||||
var host = http.Request.Host.ToString();
|
||||
var script = builder.Build($"{scheme}://{host}");
|
||||
return Results.Text(script, "text/x-shellscript");
|
||||
});
|
||||
|
||||
app.MapGet("/client.tar.gz", (IConfiguration cfg, IWebHostEnvironment env) =>
|
||||
{
|
||||
var path = cfg["Install:ClientTarballPath"]
|
||||
?? Path.Combine(env.WebRootPath ?? "wwwroot", "client.tar.gz");
|
||||
if (!File.Exists(path))
|
||||
return Results.NotFound(new { error = "client.tar.gz not found at " + path });
|
||||
return Results.File(path, "application/gzip", "client.tar.gz");
|
||||
});
|
||||
|
||||
return app;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user