From f9b0816b80793965ef044f6871a7ffd80e91d303 Mon Sep 17 00:00:00 2001 From: BaronGreenback Date: Sat, 18 Jul 2020 16:54:23 +0100 Subject: Changes a suggested. --- .../Extensions/HttpContextExtensions.cs | 34 ++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 MediaBrowser.Common/Extensions/HttpContextExtensions.cs (limited to 'MediaBrowser.Common/Extensions/HttpContextExtensions.cs') diff --git a/MediaBrowser.Common/Extensions/HttpContextExtensions.cs b/MediaBrowser.Common/Extensions/HttpContextExtensions.cs new file mode 100644 index 000000000..4bab42cc1 --- /dev/null +++ b/MediaBrowser.Common/Extensions/HttpContextExtensions.cs @@ -0,0 +1,34 @@ +using MediaBrowser.Model.Services; +using Microsoft.AspNetCore.Http; + +namespace MediaBrowser.Common.Extensions +{ + /// + /// Extention to enable the service stack request to be stored in the HttpRequest object. + /// Static class containing extension methods for . + /// + public static class HttpContextExtensions + { + private const string SERVICESTACKREQUEST = "ServiceStackRequest"; + + /// + /// Set the ServiceStack request. + /// + /// The HttpContext instance. + /// The service stack request instance. + public static void SetServiceStackRequest(this HttpContext httpContext, IRequest request) + { + httpContext.Items[SERVICESTACKREQUEST] = request; + } + + /// + /// Get the ServiceStack request. + /// + /// The HttpContext instance. + /// The service stack request instance. + public static IRequest GetServiceStack(this HttpContext httpContext) + { + return (IRequest)httpContext.Items[SERVICESTACKREQUEST]; + } + } +} -- cgit v1.2.3