using System;
using System.Linq;
using Microsoft.AspNetCore.Mvc.ApplicationModels;
namespace Jellyfin.Server.Filters
{
///
/// Searches for actions and controllers marked with and applies a custom filter.
///
public class ObsoleteEndpointConvention : IApplicationModelConvention
{
///
public void Apply(ApplicationModel application)
{
foreach (var controller in application.Controllers)
{
var isControllerObsolete = controller.Attributes.OfType().Any();
foreach (var action in controller.Actions)
{
if (isControllerObsolete || action.Attributes.OfType().Any())
{
action.Filters.Add(new ObsoleteEndpointFilter());
}
}
}
}
}
}