/// <summary> /// Processes a request to determine if it matches a known file, and if so, serves it. /// /// </summary> /// <param name="context"/> /// <returns/> public Task Invoke(HttpContext context) { var fileInfo = this._fileInfo; // In Debug mode we will load the file information all the time since the file might change. if (_options.DebugMode) { fileInfo = _options.FileProvider.GetFileInfo(_options.DefaultHtml.Value); if (!_fileInfo.Exists) { throw new InvalidOperationException($"Filename {_fileInfo.Name} does not exist. "); } } var spaContext = new SpaContext(context, _options, fileInfo, _logger); if (!spaContext.ValidateMethod()) { return(_next(context)); } if (spaContext.IsHeadMethod()) { return(spaContext.SendStatusAsync(200)); } if (_logger.IsEnabled(LogLevel.Verbose)) { _logger.LogVerbose($"Copying file {_options.DefaultHtml} to the response body for request {context.Request.Path}"); } return(spaContext.SendAsync()); }
/// <summary> /// Processes a request to determine if it matches a known file, and if so, serves it. /// /// </summary> /// <param name="context"/> /// <returns/> public Task Invoke(HttpContext context) { var fileInfo = this._fileInfo; // In Debug mode we will load the file information all the time since the file might change. if (_options.DebugMode) { fileInfo = _options.FileProvider.GetFileInfo(_options.DefaultHtml.Value); if (!_fileInfo.Exists) throw new InvalidOperationException($"Filename {_fileInfo.Name} does not exist. "); } var spaContext = new SpaContext(context, _options, fileInfo, _logger); if (!spaContext.ValidateMethod()) return _next(context); if (spaContext.IsHeadMethod()) return spaContext.SendStatusAsync(200); if (_logger.IsEnabled(LogLevel.Verbose)) _logger.LogVerbose($"Copying file {_options.DefaultHtml} to the response body for request {context.Request.Path}"); return spaContext.SendAsync(); }