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,14 +1,14 @@
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")]
[ApiController]
[ApiVersion("1.0")]
[Produces("application/json")]
public class PluginController : ControllerBase
{ {
[Route("api/plugin")]
[ApiController]
[ApiVersion("1.0")]
[Produces("application/json")]
public class PluginController : ControllerBase
{
public PluginController() public PluginController()
{ {
} }
@ -30,5 +30,4 @@ namespace ServerManager.WebApplication.Controllers
return StatusCode(StatusCodes.Status500InternalServerError, false); return StatusCode(StatusCodes.Status500InternalServerError, false);
} }
} }
}
} }

View file

@ -8,14 +8,14 @@ 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")]
[ApiController]
[ApiVersion("1.0")]
[Produces("application/json")]
public class ServerController : ControllerBase
{ {
[Route("api/server")]
[ApiController]
[ApiVersion("1.0")]
[Produces("application/json")]
public class ServerController : ControllerBase
{
private readonly IServerQueryService _serverQueryService; private readonly IServerQueryService _serverQueryService;
public ServerController(IServerQueryService serverQueryService) public ServerController(IServerQueryService serverQueryService)
@ -75,5 +75,4 @@ namespace ServerManager.WebApplication.Controllers
return StatusCode(StatusCodes.Status500InternalServerError, response); return StatusCode(StatusCodes.Status500InternalServerError, response);
} }
} }
}
} }