mirror of https://github.com/Squidex/squidex.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1.3 KiB
40 lines
1.3 KiB
// ==========================================================================
|
|
// Squidex Headless CMS
|
|
// ==========================================================================
|
|
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
|
// All rights reserved. Licensed under the MIT license.
|
|
// ==========================================================================
|
|
|
|
using Microsoft.AspNetCore.Http;
|
|
using Squidex.Infrastructure;
|
|
using Squidex.Infrastructure.Log;
|
|
|
|
namespace Squidex.Pipeline
|
|
{
|
|
public sealed class RequestLogProfilerSessionProvider : ILogProfilerSessionProvider
|
|
{
|
|
private const string ItemKey = "ProfilerSesison";
|
|
private readonly IHttpContextAccessor httpContextAccessor;
|
|
|
|
public RequestLogProfilerSessionProvider(IHttpContextAccessor httpContextAccessor)
|
|
{
|
|
this.httpContextAccessor = httpContextAccessor;
|
|
|
|
Profile.Init(this);
|
|
}
|
|
|
|
public ProfilerSession GetSession()
|
|
{
|
|
var context = httpContextAccessor?.HttpContext?.Items[ItemKey] as ProfilerSession;
|
|
|
|
return context;
|
|
}
|
|
|
|
public void Start(HttpContext httpContext, ProfilerSession session)
|
|
{
|
|
Guard.NotNull(httpContext, nameof(httpContext));
|
|
|
|
httpContext.Items[ItemKey] = session;
|
|
}
|
|
}
|
|
}
|
|
|