Ejemplo n.º 1
0
        protected async Task <IReadOnlyQueryRequest> BuildRequestAsync(
            HttpContext context,
            IServiceProvider services,
            IQueryRequestBuilder builder)
        {
            if (!_interceptorInitialized)
            {
                _interceptor = services
                               .GetService <IQueryRequestInterceptor <HttpContext> >();
                _interceptorInitialized = true;
            }

            if (_interceptor != null)
            {
                await _interceptor.OnCreateAsync(
                    context,
                    builder,
                    context.GetCancellationToken())
                .ConfigureAwait(false);
            }

            builder.SetServices(services);
            builder.TryAddProperty(nameof(HttpContext), context);
            builder.TryAddProperty(nameof(ClaimsPrincipal), context.GetUser());

            if (context.IsTracingEnabled())
            {
                builder.TryAddProperty(ContextDataKeys.EnableTracing, true);
            }

            return(builder.Create());
        }
 public async ValueTask OnRequestAsync(ISocketConnection connection, IQueryRequestBuilder requestBuilder,
                                       CancellationToken cancellationToken)
 {
     requestBuilder.TrySetServices(connection.RequestServices);
     requestBuilder.TryAddProperty(nameof(HttpContext), connection.HttpContext);
     requestBuilder.TryAddProperty(nameof(ClaimsPrincipal), connection.HttpContext.User);
 }
        public virtual ValueTask OnCreateAsync(
            HttpContext context,
            IRequestExecutor requestExecutor,
            IQueryRequestBuilder requestBuilder,
            CancellationToken cancellationToken)
        {
            requestBuilder.TrySetServices(context.RequestServices);
            requestBuilder.TryAddProperty(nameof(HttpContext), context);
            requestBuilder.TryAddProperty(nameof(ClaimsPrincipal), context.User);
            requestBuilder.TryAddProperty(nameof(CancellationToken), context.RequestAborted);

            if (context.IsTracingEnabled())
            {
                requestBuilder.TryAddProperty(WellKnownContextData.EnableTracing, true);
            }

            return(default);
Ejemplo n.º 4
0
        public virtual ValueTask OnRequestAsync(
            ISocketConnection connection,
            IQueryRequestBuilder requestBuilder,
            CancellationToken cancellationToken)
        {
            HttpContext context = connection.HttpContext;

            requestBuilder.TrySetServices(connection.RequestServices);
            requestBuilder.TryAddProperty(nameof(CancellationToken), connection.RequestAborted);
            requestBuilder.TryAddProperty(nameof(HttpContext), context);
            requestBuilder.TryAddProperty(nameof(ClaimsPrincipal), context.User);

            if (connection.HttpContext.IsTracingEnabled())
            {
                requestBuilder.TryAddProperty(ContextDataKeys.EnableTracing, true);
            }

            return(default);