2022-11-06 22:42:32 +08:00
|
|
|
using Dipper.Alioth.Options;
|
|
|
|
using Microsoft.AspNetCore.Builder;
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
|
|
|
namespace Dipper.Alioth.Web;
|
|
|
|
|
2022-11-09 22:06:06 +08:00
|
|
|
public class WebStarHost : StarHost
|
2022-11-06 22:42:32 +08:00
|
|
|
{
|
2022-11-09 22:06:06 +08:00
|
|
|
private WebStarHost()
|
2022-11-06 23:03:52 +08:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-11-09 22:06:06 +08:00
|
|
|
public static WebStarHost CreateWebHost()
|
2022-11-06 23:03:52 +08:00
|
|
|
{
|
2022-11-09 22:06:06 +08:00
|
|
|
return new WebStarHost();
|
2022-11-06 23:03:52 +08:00
|
|
|
}
|
|
|
|
|
2022-11-09 22:06:06 +08:00
|
|
|
public override void Run(string[] args, Action<StarOption> action)
|
2022-11-06 22:42:32 +08:00
|
|
|
{
|
|
|
|
var app = Configure(args, action);
|
|
|
|
app.Run();
|
|
|
|
}
|
|
|
|
|
2022-11-09 22:06:06 +08:00
|
|
|
public override Task RunAsync(string[] args, Action<StarOption> action)
|
2022-11-06 22:42:32 +08:00
|
|
|
{
|
|
|
|
var app = Configure(args, action);
|
|
|
|
|
|
|
|
return app.RunAsync();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-11-06 23:03:52 +08:00
|
|
|
private WebApplication Configure(string[] args, Action<StarOption> action)
|
2022-11-06 22:42:32 +08:00
|
|
|
{
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
2022-11-09 22:06:06 +08:00
|
|
|
builder.AddStarApp(action);
|
2022-11-06 22:42:32 +08:00
|
|
|
var app = builder.Build();
|
2022-11-09 22:06:06 +08:00
|
|
|
|
|
|
|
app.UserStarApp();
|
2022-11-06 22:42:32 +08:00
|
|
|
|
|
|
|
return app;
|
|
|
|
}
|
|
|
|
}
|