/// <summary> /// Checks whether the HTTP compression is enabled /// </summary> /// <param name="options">WebMarkupMin options</param> /// <returns>Result of check (true - compression is enabled; false - compression is disabled)</returns> public static bool IsCompressionEnabled(this WebMarkupMinOptions options) { bool isCompressionEnabled = false; if (!options.DisableCompression) { isCompressionEnabled = !options.HostingEnvironment.IsDevelopment() || options.AllowCompressionInDevelopmentEnvironment; } return(isCompressionEnabled); }
/// <summary> /// Constructs a instance of WebMarkupMin middleware /// </summary> /// <param name="next">The next middleware in the pipeline</param> /// <param name="options">WebMarkupMin options</param> /// <param name="services">The list of services</param> public WebMarkupMinMiddleware( [NotNull] RequestDelegate next, [NotNull] IOptions <WebMarkupMinOptions> options, [NotNull] IServiceProvider services) { _next = next; _options = options.Value; var minificationManagers = new List <IMarkupMinificationManager>(); var htmlMinificationManager = services.GetService <IHtmlMinificationManager>(); if (htmlMinificationManager != null) { minificationManagers.Add(htmlMinificationManager); } var xhtmlMinificationManager = services.GetService <IXhtmlMinificationManager>(); if (xhtmlMinificationManager != null) { minificationManagers.Add(xhtmlMinificationManager); } var xmlMinificationManager = services.GetService <IXmlMinificationManager>(); if (xmlMinificationManager != null) { minificationManagers.Add(xmlMinificationManager); } _minificationManagers = minificationManagers; var compressionManager = services.GetService <IHttpCompressionManager>(); if (compressionManager != null) { _compressionManager = compressionManager; } }