/// <summary> /// Uses the files middleware in aspnet 5 like environment. /// </summary> /// <param name="build">The build.</param> /// <param name="config">The configuration.</param> /// <returns></returns> /// <exception cref="System.ArgumentNullException">config</exception> public static Action <MidFunc> UseFiles( this Action <MidFunc> build, FilesConfig config) { if (build == null) { throw new ArgumentNullException("build"); } if (config == null) { throw new ArgumentNullException("config"); } build(next => new FilesMiddleware(next, config).Invoke); return(build); }
public FilesMiddleware(AppFunc next, FilesConfig options) { if (next == null) { throw new ArgumentNullException("next"); } if (options == null) { throw new ArgumentNullException("options"); } _next = next; _options = options; Handlers = new Dictionary <string, IMethodHandler>(StringComparer.OrdinalIgnoreCase); var getHandler = new GetHandler(); Handlers.Add(HttpMethodNames.Get, getHandler); Handlers.Add(HttpMethodNames.Head, getHandler); }