aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Common/Extensions/HttpContextExtensions.cs
blob: 142935c1a8af0fd842f7403938f7947eb09df7e0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using MediaBrowser.Model.Services;
using Microsoft.AspNetCore.Http;

namespace MediaBrowser.Common.Extensions
{
    /// <summary>
    /// 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];
        }
    }
}