コード例 #1
0
        /// <summary>
        /// Gets the correlation id from header , if not found a new is added to the header and returned.
        /// </summary>
        /// <returns>Correlation id for request.</returns>
        public static string GetOrAddCorrelationId(this IHeaderDictionary headers)
        {
            if (headers == null)
            {
                throw new ArgumentNullException(nameof(headers));
            }

            return(headers.TryGetValue(WellKnownHttpHeaders.CorrelationId, out var header)
                ? header.FirstOrDefault()
                : headers.AddCorrelationId(Guid.NewGuid().ToString().ToUpperInvariant()));
        }