Added new health endpoint

This commit is contained in:
Brett Hewitson 2023-02-23 14:36:37 +10:00
parent 7addb5b6f7
commit 95c8da2053
3 changed files with 108 additions and 83 deletions

View file

@ -0,0 +1,27 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
namespace ServerManager.WebApplication.Controllers;
[Route("api/[controller]")]
[ApiController]
[ApiVersion("1.0")]
[Produces("application/json")]
public class HealthController : ControllerBase
{
[HttpGet()]
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public IActionResult Get()
{
try
{
return Ok();
}
catch
{
return StatusCode(StatusCodes.Status500InternalServerError, false);
}
}
}

View file

@ -1,8 +1,8 @@
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
namespace ServerManager.WebApplication.Controllers namespace ServerManager.WebApplication.Controllers;
{
[Route("api/plugin")] [Route("api/plugin")]
[ApiController] [ApiController]
[ApiVersion("1.0")] [ApiVersion("1.0")]
@ -31,4 +31,3 @@ namespace ServerManager.WebApplication.Controllers
} }
} }
} }
}

View file

@ -8,8 +8,8 @@ using ServerManager.WebApplication.Services;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
namespace ServerManager.WebApplication.Controllers namespace ServerManager.WebApplication.Controllers;
{
[Route("api/server")] [Route("api/server")]
[ApiController] [ApiController]
[ApiVersion("1.0")] [ApiVersion("1.0")]
@ -76,4 +76,3 @@ namespace ServerManager.WebApplication.Controllers
} }
} }
} }
}