diff --git a/Emby.Server.Implementations/Services/HttpContextExtension.cs b/Emby.Server.Implementations/Services/HttpContextExtension.cs new file mode 100644 index 000000000..6d3a600ab --- /dev/null +++ b/Emby.Server.Implementations/Services/HttpContextExtension.cs @@ -0,0 +1,33 @@ +using MediaBrowser.Model.Services; +using Microsoft.AspNetCore.Http; + +namespace Emby.Server.Implementations.Services +{ + /// + /// Extention to enable the service stack request to be stored in the HttpRequest object. + /// + public static class HttpContextExtension + { + private const string SERVICESTACKREQUEST = "ServiceRequestStack"; + + /// + /// Set the service stack request. + /// + /// The HttpContext instance. + /// The IRequest instance. + public static void SetServiceStackRequest(this HttpContext httpContext, IRequest request) + { + httpContext.Items[SERVICESTACKREQUEST] = request; + } + + /// + /// Get the service stack request. + /// + /// The HttpContext instance. + /// The service stack request instance. + public static IRequest GetServiceStack(this HttpContext httpContext) + { + return (IRequest)httpContext.Items[SERVICESTACKREQUEST]; + } + } +}