Added Imagesharp to the website stuff

This commit is contained in:
Bjarke Berg
2020-02-24 11:26:34 +01:00
parent 5517186cb7
commit 1d6e423b98
9 changed files with 29 additions and 51 deletions

View File

@@ -1,18 +1,24 @@
using System;
using Microsoft.AspNetCore.Builder;
using SixLabors.ImageSharp.Web.DependencyInjection;
namespace Umbraco.Web.Website.AspNetCore
{
public static class UmbracoBackOfficeApplicationBuilderExtensions
{
public static IApplicationBuilder UseUmbracoWebsite(this IApplicationBuilder builder)
public static IApplicationBuilder UseUmbracoWebsite(this IApplicationBuilder app)
{
if (builder == null)
if (app == null)
{
throw new ArgumentNullException(nameof(builder));
throw new ArgumentNullException(nameof(app));
}
return builder.UseMiddleware<UmbracoWebsiteMiddleware>();
// Important we handle image manipulations before the static files, otherwise the querystring is just ignored.
app.UseImageSharp();
app.UseStaticFiles();
return app;
}
}
}

View File

@@ -1,21 +0,0 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
namespace Umbraco.Web.Website.AspNetCore
{
public class UmbracoWebsiteMiddleware
{
private readonly RequestDelegate _next;
public UmbracoWebsiteMiddleware(RequestDelegate next)
{
_next = next;
}
public async Task InvokeAsync(HttpContext context)
{
// Call the next delegate/middleware in the pipeline
await _next(context);
}
}
}

View File

@@ -1,4 +1,5 @@
using Microsoft.Extensions.DependencyInjection;
using SixLabors.ImageSharp.Web.DependencyInjection;
namespace Umbraco.Web.Website.AspNetCore
{
@@ -6,6 +7,9 @@ namespace Umbraco.Web.Website.AspNetCore
{
public static IServiceCollection AddUmbracoWebsite(this IServiceCollection services)
{
services.AddImageSharp();
return services;
}