Skip to content
This repository was archived by the owner on Dec 14, 2018. It is now read-only.

Commit

Permalink
[Fixes #4152] Add HttpOptionsAttribute
Browse files Browse the repository at this point in the history
  • Loading branch information
javiercn committed Mar 10, 2016
1 parent 6b369ef commit 9ddd909
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions src/Microsoft.AspNetCore.Mvc.Core/HttpOptionsAttribute.cs
Original file line number Diff line number Diff line change
@@ -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));
}
}
}
}

0 comments on commit 9ddd909

Please sign in to comment.