/// <summary> /// Invokes ResponseHeaderMiddleware at some point in the pipeline /// </summary> /// <param name="builder">application builder</param> /// <param name="configureOptions">header name options (defaults used, if null)</param> /// <returns>a reference to the applicaton builder (for fluent construction)</returns> public static IApplicationBuilder UseResponseHeader( this IApplicationBuilder builder, Action <ResponseHeaderMiddlewareOptions> configureOptions = null) { var options = new ResponseHeaderMiddlewareOptions(); //configure the options, unless configureOptions is null configureOptions?.Invoke(options); //use the middleware return(builder.UseMiddleware <ResponseHeaderMiddleware>(options)); }
/// <summary> /// Constructs a new ResponseHeaderMiddleware object /// with the required delegate and options /// </summary> /// <param name="next">delegate used to invoke the next middleware in the pipeline</param> /// <param name="options">a dictionary of new headers to add</param> public ResponseHeaderMiddleware( RequestDelegate next, ResponseHeaderMiddlewareOptions options) { _next = next; _options = options; }