// 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.Extensions.Options;
using Winsoft.GOV.XF.WXCore.OAuth;
namespace Microsoft.AspNetCore.Builder
{
///
/// Extension methods to add WeChat authentication capabilities to an HTTP application pipeline.
///
public static class WeChatAppBuilderExtensions
{
///
/// Adds the middleware to the specified , which enables WeChat authentication capabilities.
///
/// The to add the middleware to.
/// A reference to this instance after the operation has completed.
public static IApplicationBuilder UseWeChatAuthentication(this IApplicationBuilder app)
{
if (app == null)
{
throw new ArgumentNullException(nameof(app));
}
return app.UseMiddleware();
}
///
/// Adds the middleware to the specified , which enables WeChat authentication capabilities.
///
/// The to add the middleware to.
/// A that specifies options for the middleware.
/// A reference to this instance after the operation has completed.
public static IApplicationBuilder UseWeChatAuthentication(this IApplicationBuilder app, WeChatOptions options)
{
if (app == null)
{
throw new ArgumentNullException(nameof(app));
}
if (options == null)
{
throw new ArgumentNullException(nameof(options));
}
return app.UseMiddleware(Options.Create(options));
}
}
}