diff options
| author | BaronGreenback <jimcartlidge@yahoo.co.uk> | 2020-07-18 16:54:23 +0100 |
|---|---|---|
| committer | BaronGreenback <jimcartlidge@yahoo.co.uk> | 2020-07-18 16:54:23 +0100 |
| commit | f9b0816b80793965ef044f6871a7ffd80e91d303 (patch) | |
| tree | 0806a296b6c1e903eef40ad5b940eb7d278751f1 /MediaBrowser.Common/Extensions/HttpContextExtensions.cs | |
| parent | 0f696104aca3309145b2e7f4169c4cf1be8ad81a (diff) | |
Changes a suggested.
Diffstat (limited to 'MediaBrowser.Common/Extensions/HttpContextExtensions.cs')
| -rw-r--r-- | MediaBrowser.Common/Extensions/HttpContextExtensions.cs | 34 |
1 files changed, 34 insertions, 0 deletions
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 +{ + /// <summary> + /// Extention to enable the service stack request to be stored in the HttpRequest object. + /// Static class containing extension methods for <see cref="HttpContext"/>. + /// </summary> + public static class HttpContextExtensions + { + private const string SERVICESTACKREQUEST = "ServiceStackRequest"; + + /// <summary> + /// Set the ServiceStack request. + /// </summary> + /// <param name="httpContext">The HttpContext instance.</param> + /// <param name="request">The service stack request instance.</param> + public static void SetServiceStackRequest(this HttpContext httpContext, IRequest request) + { + httpContext.Items[SERVICESTACKREQUEST] = request; + } + + /// <summary> + /// Get the ServiceStack request. + /// </summary> + /// <param name="httpContext">The HttpContext instance.</param> + /// <returns>The service stack request instance.</returns> + public static IRequest GetServiceStack(this HttpContext httpContext) + { + return (IRequest)httpContext.Items[SERVICESTACKREQUEST]; + } + } +} |
