diff --git a/src/Microsoft.AspNetCore.Mvc.Core/HttpOptionsAttribute.cs b/src/Microsoft.AspNetCore.Mvc.Core/HttpOptionsAttribute.cs new file mode 100644 index 0000000000..e7103fa6f9 --- /dev/null +++ b/src/Microsoft.AspNetCore.Mvc.Core/HttpOptionsAttribute.cs @@ -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 +{ + /// + /// Identifies an action that only supports the HTTP OPTIONS method. + /// + public class HttpOptionsAttribute : HttpMethodAttribute + { + private static readonly IEnumerable _supportedMethods = new string[] { "OPTIONS" }; + + /// + /// Creates a new . + /// + public HttpOptionsAttribute() + : base(_supportedMethods) + { + } + + /// + /// Creates a new with the given route template. + /// + /// The route template. May not be null. + public HttpOptionsAttribute(string template) + : base(_supportedMethods, template) + { + if (template == null) + { + throw new ArgumentNullException(nameof(template)); + } + } + } +} \ No newline at end of file