andrewlock / NetEscapades.AspNetCore.SecurityHeaders

Small package to allow adding security headers to ASP.NET Core websites
MIT License
701 stars 73 forks source link

Changed OnResponseStarting method #165

Closed castilhera closed 2 months ago

castilhera commented 3 months ago

OnResponseStarting is no longer a static method, so we can use the _policy and CustomHeaderService properties directly instead of passing a tuple to the method with those properties. For context, we forward the object of the method that called it.

context.Response.OnStarting(() => OnResponseStarting(context));
private Task OnResponseStarting(HttpContext context) { }

This way, we eliminate the need for boxing and unboxing parameters.

andrewlock commented 2 months ago

Thanks for this @castilhera, but given that this has all changed significantly in #190, and given this actually allocates more than using the static method, I'm going to close this. Thanks anyway!