// 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.Http;
using Microsoft.AspNet.StaticFiles;
namespace Microsoft.AspNet.Builder
{
///
/// Extension methods for the DefaultFilesMiddleware
///
public static class DefaultFilesExtensions
{
///
/// Enables default file mapping on the current path
///
///
///
public static IApplicationBuilder UseDefaultFiles(this IApplicationBuilder builder)
{
if (builder == null)
{
throw new ArgumentNullException(nameof(builder));
}
return builder.UseDefaultFiles(new DefaultFilesOptions());
}
///
/// Enables default file mapping for the given request path
///
///
/// The relative request path.
///
public static IApplicationBuilder UseDefaultFiles(this IApplicationBuilder builder, string requestPath)
{
if (builder == null)
{
throw new ArgumentNullException(nameof(builder));
}
return builder.UseDefaultFiles(new DefaultFilesOptions() { RequestPath = new PathString(requestPath) });
}
///
/// Enables default file mapping with the given options
///
///
///
///
public static IApplicationBuilder UseDefaultFiles(this IApplicationBuilder builder, DefaultFilesOptions options)
{
if (builder == null)
{
throw new ArgumentNullException(nameof(builder));
}
if (options == null)
{
throw new ArgumentNullException(nameof(options));
}
return builder.UseMiddleware(options);
}
}
}