// 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 Microsoft.AspNet.HttpOverrides;
using Microsoft.Extensions.Options;
namespace Microsoft.AspNet.Builder
{
public static class HttpMethodOverrideExtensions
{
///
/// Allows incoming POST request to override method type with type specified in header.
///
///
///
public static IApplicationBuilder UseHttpMethodOverride(this IApplicationBuilder builder)
{
if (builder == null)
{
throw new ArgumentNullException(nameof(builder));
}
return builder.UseMiddleware();
}
///
/// Allows incoming POST request to override method type with type specified in form.
///
///
/// Denotes the element that contains the name of the resulting method type.
///
public static IApplicationBuilder UseHttpMethodOverride(this IApplicationBuilder builder, HttpMethodOverrideOptions options)
{
if (builder == null)
{
throw new ArgumentNullException(nameof(builder));
}
if (options == null)
{
throw new ArgumentNullException(nameof(options));
}
return builder.UseMiddleware(Options.Create(options));
}
}
}