[Fixes #4152] Add HttpOptionsAttribute
This commit is contained in:
parent
52ab065942
commit
2b7a98a4d6
|
|
@ -0,0 +1,38 @@
|
||||||
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Microsoft.AspNetCore.Mvc.Routing;
|
||||||
|
|
||||||
|
namespace Microsoft.AspNetCore.Mvc
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Identifies an action that only supports the HTTP OPTIONS method.
|
||||||
|
/// </summary>
|
||||||
|
public class HttpOptionsAttribute : HttpMethodAttribute
|
||||||
|
{
|
||||||
|
private static readonly IEnumerable<string> _supportedMethods = new string[] { "OPTIONS" };
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a new <see cref="HttpOptionsAttribute"/>.
|
||||||
|
/// </summary>
|
||||||
|
public HttpOptionsAttribute()
|
||||||
|
: base(_supportedMethods)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a new <see cref="HttpOptionsAttribute"/> with the given route template.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="template">The route template. May not be null.</param>
|
||||||
|
public HttpOptionsAttribute(string template)
|
||||||
|
: base(_supportedMethods, template)
|
||||||
|
{
|
||||||
|
if (template == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(template));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue