2023-12-30 03:54:41 +00:00
|
|
|
using Microsoft.Extensions.Hosting;
|
|
|
|
|
|
|
|
|
|
namespace BotSharp.OpenAPI.Controllers;
|
|
|
|
|
|
|
|
|
|
[Authorize]
|
|
|
|
|
[ApiController]
|
|
|
|
|
public class ApplicationController : ControllerBase
|
|
|
|
|
{
|
|
|
|
|
private readonly IServiceProvider _services;
|
|
|
|
|
public ApplicationController(IServiceProvider services)
|
|
|
|
|
{
|
|
|
|
|
_services = services;
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-08 18:06:13 +00:00
|
|
|
[AllowAnonymous]
|
|
|
|
|
[HttpGet("/app/health")]
|
|
|
|
|
public IActionResult Health()
|
|
|
|
|
{
|
|
|
|
|
return Ok(new { });
|
|
|
|
|
}
|
|
|
|
|
|
2023-12-30 03:54:41 +00:00
|
|
|
[HttpGet("/app/shutdown")]
|
|
|
|
|
public IActionResult Restart()
|
|
|
|
|
{
|
|
|
|
|
var app = _services.GetRequiredService<IHostApplicationLifetime>();
|
|
|
|
|
app.StopApplication();
|
|
|
|
|
return Ok();
|
|
|
|
|
}
|
|
|
|
|
}
|