コード例 #1
0
 /// <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);
 }
コード例 #2
0
 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;
 }
コード例 #3
0
        /// <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));
        }
コード例 #4
0
 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;
 }
コード例 #5
0
        /// <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.  ");
            
        }
コード例 #6
0
        /// <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.  ");
            }
        }
コード例 #7
0
 /// <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);
 }
コード例 #8
0
 /// <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));
 }