You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Lidarr/src/Lidarr.Http/VersionedApiControllerAttri...

35 lines
1.1 KiB

using System;
using Microsoft.AspNetCore.Cors.Infrastructure;
using Microsoft.AspNetCore.Mvc.Infrastructure;
using Microsoft.AspNetCore.Mvc.Routing;
namespace Lidarr.Http
{
public class VersionedApiControllerAttribute : Attribute, IRouteTemplateProvider, IEnableCorsAttribute, IApiBehaviorMetadata
{
public const string API_CORS_POLICY = "ApiCorsPolicy";
public const string CONTROLLER_RESOURCE = "[controller]";
public VersionedApiControllerAttribute(int version, string resource = CONTROLLER_RESOURCE)
{
Resource = resource;
Template = $"api/v{version}/{resource}";
PolicyName = API_CORS_POLICY;
}
public string Resource { get; }
public string Template { get; }
public int? Order => 2;
public string Name { get; set; }
public string PolicyName { get; set; }
}
public class V1ApiControllerAttribute : VersionedApiControllerAttribute
{
public V1ApiControllerAttribute(string resource = "[controller]")
: base(1, resource)
{
}
}
}