/// <summary> /// Initializes a new instance of the <see /// cref="ResponseHeadersMiddleware"/> class. /// </summary> /// <param name="next"> /// A function used to continue processing of an HTTP request. /// </param> /// <param name="loggerFactory"> /// A type used to provide <see cref="ILogger"/> instances. /// </param> /// <param name="options"> /// A container used to specify the options for the middleware. /// </param> public ResponseHeadersMiddleware(RequestDelegate next, ILoggerFactory loggerFactory, IOptions <ResponseHeadersOptions> options) { if (next == null) { throw new ArgumentNullException(nameof(next)); } //if (loggerFactory == null) // throw new ArgumentNullException(nameof(loggerFactory)); if (options == null) { throw new ArgumentNullException(nameof(options)); } this.next = next; this.options = options.Value; }
/// <summary> /// Initializes a new instance of the <see /// cref="ResponseHeadersOptionsBuilder"/> class. /// </summary> public ResponseHeadersOptionsBuilder() { options = new ResponseHeadersOptions(); }
/// <summary> /// Specifies additional HTTP headers to add to responses. /// </summary> /// <param name="app">The builder to configure.</param> /// <param name="options">Specifies the response headers to add.</param> /// <returns> /// A reference to <paramref name="app"/> with the configured response headers. /// </returns> public static IApplicationBuilder UseResponseHeaders(this IApplicationBuilder app, ResponseHeadersOptions options) { if (app == null) { throw new ArgumentNullException(nameof(app)); } if (options == null) { throw new ArgumentNullException(nameof(options)); } return(app.UseMiddleware <ResponseHeadersMiddleware>(Options.Create(options))); }