| | | 1 | | <# |
| | | 2 | | .SYNOPSIS |
| | | 3 | | Set exposed headers for a CORS policy builder. |
| | | 4 | | .DESCRIPTION |
| | | 5 | | Configures which response headers are exposed to browser JavaScript by adding |
| | | 6 | | the Access-Control-Expose-Headers list to the CORS policy. |
| | | 7 | | .PARAMETER Builder |
| | | 8 | | The CorsPolicyBuilder to configure. Accepts from pipeline. |
| | | 9 | | .PARAMETER Headers |
| | | 10 | | One or more header names to expose to the client. |
| | | 11 | | .EXAMPLE |
| | | 12 | | New-KrCorsPolicyBuilder | Set-KrCorsExposedHeader -Headers 'X-Total-Count','X-Page-Number' |
| | | 13 | | .OUTPUTS |
| | | 14 | | Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicyBuilder |
| | | 15 | | #> |
| | | 16 | | function Set-KrCorsExposedHeader { |
| | | 17 | | [KestrunRuntimeApi('Definition')] |
| | | 18 | | [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseShouldProcessForStateChangingFunctions', '')] |
| | | 19 | | [CmdletBinding()] |
| | | 20 | | [OutputType([Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicyBuilder])] |
| | | 21 | | param( |
| | | 22 | | [Parameter(Mandatory, ValueFromPipeline)] |
| | | 23 | | [Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicyBuilder]$Builder, |
| | | 24 | | |
| | | 25 | | [Parameter(Mandatory)] |
| | | 26 | | [string[]]$Headers |
| | | 27 | | ) |
| | | 28 | | process { |
| | | 29 | | # ASP.NET Core: WithExposedHeaders adds Access-Control-Expose-Headers |
| | 0 | 30 | | $Builder.WithExposedHeaders($Headers) | Out-Null |
| | 0 | 31 | | $Builder |
| | | 32 | | } |
| | | 33 | | } |