示例#1
0
        /// <summary>
        /// Add the ResponseHeaders middleware to include the configured response headers with each response.
        /// </summary>
        /// <param name="app"></param>
        public static IApplicationBuilder UseResponseHeaders(this IApplicationBuilder app, Action <ResponseHeaderBuilder> options)
        {
            var builder = new ResponseHeaderBuilder();

            options?.Invoke(builder);
            var policy = builder.Build();

            return(app.UseMiddleware <ResponseHeadersMiddleware>(policy));
        }
示例#2
0
        /// <summary>
        /// Configure the response headers middleware and add it to the services collection.
        /// </summary>
        /// <param name="services"></param>
        /// <param name="options"></param>
        /// <returns></returns>
        public static IServiceCollection AddResponseHeaders(this IServiceCollection services, Action <ResponseHeaderBuilder> options)
        {
            var builder = new ResponseHeaderBuilder();

            options?.Invoke(builder);
            var policy = builder.Build();

            return(services.AddSingleton(policy));
        }
示例#3
0
        /// <summary>
        /// Add the ResponseHeaders middleware to include the configured response headers with each response.
        /// </summary>
        /// <param name="app"></param>
        public static IApplicationBuilder UseResponseHeaders(this IApplicationBuilder app, ResponseHeaderBuilder builder)
        {
            var policy = builder.Build();

            return(app.UseMiddleware <ResponseHeadersMiddleware>(policy));
        }