34 lines
1.2 KiB
C#
34 lines
1.2 KiB
C#
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 GetServiceStackRequest(this HttpContext httpContext)
|
|
{
|
|
return (IRequest)httpContext.Items[ServiceStackRequest];
|
|
}
|
|
}
|
|
}
|