// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
using System;
using Microsoft.AspNet.Abstractions;
using Microsoft.AspNet.StaticFiles;
namespace Microsoft.AspNet
{
///
/// Extension methods for the StaticFileMiddleware
///
public static class StaticFileExtensions
{
///
/// Enables static file serving for the current request path from the current directory
///
///
///
public static IBuilder UseStaticFiles(this IBuilder builder)
{
return UseStaticFiles(builder, new StaticFileOptions());
}
///
/// Enables static file serving for the given request path from the directory of the same name
///
///
/// The relative request path and physical path.
///
public static IBuilder UseStaticFiles(this IBuilder builder, string requestPath)
{
return UseStaticFiles(builder, new StaticFileOptions() { RequestPath = new PathString(requestPath) });
}
///
/// Enables static file serving with the given options
///
///
///
///
public static IBuilder UseStaticFiles(this IBuilder builder, StaticFileOptions options)
{
if (builder == null)
{
throw new ArgumentNullException("builder");
}
return builder.Use(next => new StaticFileMiddleware(next, options).Invoke);
}
}
}