rename Cache service to OutputCache
This commit is contained in:
@ -1,31 +0,0 @@
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
using Oqtane.Models;
|
||||
using Oqtane.Services;
|
||||
using Oqtane.Shared;
|
||||
|
||||
namespace Oqtane.Controllers
|
||||
{
|
||||
[Route(ControllerRoutes.ApiRoute)]
|
||||
public class CacheController : Controller
|
||||
{
|
||||
private readonly ICacheService _cacheService;
|
||||
|
||||
public CacheController(ICacheService cacheService)
|
||||
{
|
||||
_cacheService = cacheService;
|
||||
}
|
||||
|
||||
// DELETE api/<controller>/outputCache/evictByTag/{tag}
|
||||
[HttpDelete("outputCache/evictByTag/{tag}")]
|
||||
[Authorize(Roles = RoleNames.Admin)]
|
||||
public async Task EvictOutputCacheByTag(string tag, CancellationToken cancellationToken = default)
|
||||
{
|
||||
await _cacheService.EvictOutputCacheByTag(tag, cancellationToken);
|
||||
}
|
||||
}
|
||||
}
|
56
Oqtane.Server/Controllers/EndpointController.cs
Normal file
56
Oqtane.Server/Controllers/EndpointController.cs
Normal file
@ -0,0 +1,56 @@
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Oqtane.Models;
|
||||
using Oqtane.Shared;
|
||||
using System.Linq;
|
||||
using Microsoft.AspNetCore.Mvc.Controllers;
|
||||
using Microsoft.AspNetCore.Routing;
|
||||
|
||||
namespace Oqtane.Controllers
|
||||
{
|
||||
[Route(ControllerRoutes.ApiRoute)]
|
||||
public class EndpointController : Controller
|
||||
{
|
||||
private readonly IEnumerable<EndpointDataSource> _endpointSources;
|
||||
|
||||
public EndpointController(IEnumerable<EndpointDataSource> endpointSources)
|
||||
{
|
||||
_endpointSources = endpointSources;
|
||||
}
|
||||
|
||||
// GET api/<controller>
|
||||
[HttpGet]
|
||||
[Authorize(Roles = RoleNames.Host)]
|
||||
public ActionResult Get()
|
||||
{
|
||||
var endpoints = _endpointSources
|
||||
.SelectMany(item => item.Endpoints)
|
||||
.OfType<RouteEndpoint>();
|
||||
|
||||
var output = endpoints.Select(
|
||||
item =>
|
||||
{
|
||||
var controller = item.Metadata
|
||||
.OfType<ControllerActionDescriptor>()
|
||||
.FirstOrDefault();
|
||||
var action = controller != null
|
||||
? $"{controller.ControllerName}.{controller.ActionName}"
|
||||
: null;
|
||||
var controllerMethod = controller != null
|
||||
? $"{controller.ControllerTypeInfo.FullName}:{controller.MethodInfo.Name}"
|
||||
: null;
|
||||
return new
|
||||
{
|
||||
Method = item.Metadata.OfType<HttpMethodMetadata>().FirstOrDefault()?.HttpMethods?[0],
|
||||
Route = $"/{item.RoutePattern.RawText.TrimStart('/')}",
|
||||
Action = action,
|
||||
ControllerMethod = controllerMethod
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
return Json(output);
|
||||
}
|
||||
}
|
||||
}
|
30
Oqtane.Server/Controllers/OutputCacheController.cs
Normal file
30
Oqtane.Server/Controllers/OutputCacheController.cs
Normal file
@ -0,0 +1,30 @@
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
using Oqtane.Models;
|
||||
using Oqtane.Services;
|
||||
using Oqtane.Shared;
|
||||
|
||||
namespace Oqtane.Controllers
|
||||
{
|
||||
[Route(ControllerRoutes.ApiRoute)]
|
||||
public class OutputCacheController : Controller
|
||||
{
|
||||
private readonly IOutputCacheService _cacheService;
|
||||
|
||||
public OutputCacheController(IOutputCacheService cacheService)
|
||||
{
|
||||
_cacheService = cacheService;
|
||||
}
|
||||
|
||||
// DELETE api/<controller>/{tag}
|
||||
[HttpDelete("{tag}")]
|
||||
[Authorize(Roles = RoleNames.Admin)]
|
||||
public async Task EvictByTag(string tag)
|
||||
{
|
||||
await _cacheService.EvictByTag(tag);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user