Exemplo n.º 1
0
        /// <summary>
        /// Invoke the middleware.
        /// </summary>
        /// <param name="context">The <see cref="HttpContext"/>.</param>
        /// <param name="logger">Represents a type used to perform logging.</param>
        public async Task Invoke(HttpContext context, ILogger <RequestProfilerModel> logger)
        {
            var loggingHandler = _requestResponseHandler ?? DefaultLoggingHandler;
            var model          = new RequestProfilerModel(context);
            await model.SnapRequestBody();

            if (await model.NextAndSnapResponceBody(_next, _contentTypes))
            {
                await loggingHandler(logger, model);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Invoke the middleware.
        /// </summary>
        /// <param name="context">The <see cref="HttpContext"/>.</param>
        /// <param name="logger">Represents a type used to perform logging.</param>
        public async Task Invoke(HttpContext context, ILogger <RequestProfilerModel> logger)
        {
            // Write request body to Application Insights.
            var loggingHandler = _options.LogHandler ?? DefaultLoggingHandler;
            var model          = new RequestProfilerModel(context);
            await model.SnapRequestBody();

            if (await model.NextAndSnapResponceBody(_next, _options.ContentTypes))
            {
                await loggingHandler(logger, model);
            }
        }