From 2b7a98a4d6b7523cd0320ea2ce36702d98f8beea Mon Sep 17 00:00:00 2001 From: jacalvar Date: Mon, 7 Mar 2016 19:29:06 -0800 Subject: [PATCH] [Fixes #4152] Add HttpOptionsAttribute --- .../HttpOptionsAttribute.cs | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 src/Microsoft.AspNetCore.Mvc.Core/HttpOptionsAttribute.cs 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