/// <summary> /// Enables static file serving for the given request path /// /// </summary> /// <param name="builder"/> /// <param name="defaultHtml">The default html to serve.</param> /// <returns/> public static IApplicationBuilder UseSpa(this IApplicationBuilder builder, string defaultHtml) { var options = new SpaOptions(); var pathString = new PathString(defaultHtml); options.DefaultHtml = pathString; return builder.UseSpa(options); }
public SpaContext(HttpContext context, SpaOptions options, IFileInfo fileInfo, ILogger logger) { Debug.Assert(fileInfo.Exists, $"The file {fileInfo.Name} does not exist"); _context = context; _options = options; _logger = logger; _fileInfo = fileInfo; }
/// <summary> /// Enables static file serving for the given request path /// /// </summary> /// <param name="builder"/> /// <param name="defaultHtml">The default html to serve.</param> /// <returns/> public static IApplicationBuilder UseSpa(this IApplicationBuilder builder, string defaultHtml) { var options = new SpaOptions(); var pathString = new PathString(defaultHtml); options.DefaultHtml = pathString; return(builder.UseSpa(options)); }
/// <summary> /// Creates a new instance of the StaticFileMiddleware. /// /// </summary> /// <param name="next">The next middleware in the pipeline.</param> /// <param name="hostingEnv">The hosting environment.</param> /// <param name="options">The configuration options.</param> /// <param name="loggerFactory">An <see cref="T:Microsoft.Framework.Logging.ILoggerFactory"/> instance used to create loggers.</param> public SpaMiddleware(RequestDelegate next, IHostingEnvironment hostingEnv, SpaOptions options, ILoggerFactory loggerFactory) { options.ResolveFileProvider(hostingEnv); _next = next; _options = options; _logger = loggerFactory.CreateLogger<SpaMiddleware>(); // Lookup the file information. _fileInfo = _options.FileProvider.GetFileInfo(options.DefaultHtml.Value); if (!_fileInfo.Exists) throw new InvalidOperationException($"Filename {_fileInfo.Name} does not exist. "); }
/// <summary> /// Creates a new instance of the StaticFileMiddleware. /// /// </summary> /// <param name="next">The next middleware in the pipeline.</param> /// <param name="hostingEnv">The hosting environment.</param> /// <param name="options">The configuration options.</param> /// <param name="loggerFactory">An <see cref="T:Microsoft.Framework.Logging.ILoggerFactory"/> instance used to create loggers.</param> public SpaMiddleware(RequestDelegate next, IHostingEnvironment hostingEnv, SpaOptions options, ILoggerFactory loggerFactory) { options.ResolveFileProvider(hostingEnv); _next = next; _options = options; _logger = loggerFactory.CreateLogger <SpaMiddleware>(); // Lookup the file information. _fileInfo = _options.FileProvider.GetFileInfo(options.DefaultHtml.Value); if (!_fileInfo.Exists) { throw new InvalidOperationException($"Filename {_fileInfo.Name} does not exist. "); } }
/// <summary> /// Enables static file serving with the given options /// /// </summary> /// <param name="builder"/><param name="options"/> /// <returns/> public static IApplicationBuilder UseSpa(this IApplicationBuilder builder, SpaOptions options) { return builder.UseMiddleware<SpaMiddleware>(options); }
/// <summary> /// Enables static file serving with the given options /// /// </summary> /// <param name="builder"/><param name="options"/> /// <returns/> public static IApplicationBuilder UseSpa(this IApplicationBuilder builder, SpaOptions options) { return(builder.UseMiddleware <SpaMiddleware>(options)); }