New endpoint for web profiling dashboard (#13038)

* Endpoint for web profiling dashboard

* Add profiling API contract
This commit is contained in:
Kenn Jacobsen
2022-09-22 13:41:26 +02:00
committed by GitHub
parent b9f58a7bc4
commit 12a341f67d
4 changed files with 72 additions and 0 deletions

View File

@@ -0,0 +1,13 @@
using Microsoft.AspNetCore.Mvc;
using NSwag.Annotations;
using Umbraco.New.Cms.Web.Common.Routing;
namespace Umbraco.Cms.ManagementApi.Controllers.Profiling;
[ApiVersion("1.0")]
[ApiController]
[BackOfficeRoute("api/v{version:apiVersion}/profiling")]
[OpenApiTag("Profiling")]
public class ProfilingControllerBase : ManagementApiControllerBase
{
}

View File

@@ -0,0 +1,19 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Umbraco.Cms.Core.Hosting;
using Umbraco.Cms.ManagementApi.ViewModels.Profiling;
namespace Umbraco.Cms.ManagementApi.Controllers.Profiling;
public class StatusProfilingController : ProfilingControllerBase
{
private readonly IHostingEnvironment _hosting;
public StatusProfilingController(IHostingEnvironment hosting) => _hosting = hosting;
[HttpGet("status")]
[MapToApiVersion("1.0")]
[ProducesResponseType(typeof(ProfilingStatusViewModel), StatusCodes.Status200OK)]
public async Task<ActionResult<ProfilingStatusViewModel>> Status()
=> await Task.FromResult(Ok(new ProfilingStatusViewModel(_hosting.IsDebugMode)));
}

View File

@@ -253,6 +253,26 @@
}
}
}
},
"/umbraco/api/v1/profiling/status": {
"get": {
"tags": [
"Profiling"
],
"operationId": "StatusProfiling_Status",
"responses": {
"200": {
"description": "",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ProfilingStatusViewModel"
}
}
}
}
}
}
}
},
"components": {
@@ -535,6 +555,15 @@
"type": "string"
}
}
},
"ProfilingStatusViewModel": {
"type": "object",
"additionalProperties": false,
"properties": {
"enabled": {
"type": "boolean"
}
}
}
}
},
@@ -545,6 +574,9 @@
{
"name": "Server"
},
{
"name": "Profiling"
},
{
"name": "Install"
}

View File

@@ -0,0 +1,8 @@
namespace Umbraco.Cms.ManagementApi.ViewModels.Profiling;
public class ProfilingStatusViewModel
{
public ProfilingStatusViewModel(bool enabled) => Enabled = enabled;
public bool Enabled { get; }
}