示例#1
0
 public CorrelationIdMiddleware(RequestDelegate next, IOptions <CorrelationIdOptions> options)
 {
     _next    = next ?? throw new ArgumentNullException(nameof(next));
     _options = options.Value ?? throw new ArgumentNullException(nameof(options));
 }
示例#2
0
        public static IApplicationBuilder UseCorrelationId(this IApplicationBuilder app, CorrelationIdOptions options)
        {
            app.NotNull();
            options.NotNull();
            if (app.ApplicationServices.GetService(typeof(ICorrelationContextFactory)) == null)
            {
                throw new InvalidOperationException("Unable to find the required services. You must call the AddCorrelationId method in ConfigureServices in the application startup code.");
            }

            return(app.UseMiddleware <CorrelationIdMiddleware>(Options.Create(options)));
        }