< Summary - Kestrun — Combined Coverage

Information
Class: Public.Middleware.Cors.Set-KrCorsHeader
Assembly: Kestrun.PowerShell.Public
File(s): /home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Public/Middleware/Cors/Set-KrCorsHeader.ps1
Tag: Kestrun/Kestrun@0d738bf294e6281b936d031e1979d928007495ff
Line coverage
0%
Covered lines: 0
Uncovered lines: 3
Coverable lines: 3
Total lines: 43
Line coverage: 0%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100 12/14/2025 - 20:04:52 Line coverage: 0% (0/3) Total lines: 43 Tag: Kestrun/Kestrun@a05ac8de57c6207e227b92ba360e9d58869ac80a

Metrics

File(s)

/home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Public/Middleware/Cors/Set-KrCorsHeader.ps1

#LineLine coverage
 1<#
 2.SYNOPSIS
 3    Set CORS headers for a given CORS policy builder.
 4.DESCRIPTION
 5    This function sets CORS headers for a given CORS policy builder. It supports setting any header or specific headers 
 6.PARAMETER Builder
 7    The CORS policy builder to set the headers for. This parameter is mandatory and must be provided.
 8.PARAMETER Any
 9    A switch parameter to allow any header. If this parameter is provided, the function will set the CORS policy to allo
 10.PARAMETER Headers
 11    An array of strings representing the specific headers to allow. This parameter is mandatory when the 'Any' switch pa
 12.EXAMPLE
 13    New-KrCorsPolicyBuilder | Set-KrCorsHeader -Any
 14    This example sets the CORS policy to allow any header.
 15.EXAMPLE
 16    New-KrCorsPolicyBuilder | Set-KrCorsHeader -Headers @('Content-Type', 'Authorization')
 17    This example sets the CORS policy to allow specific headers ('Content-Type' and 'Authorization').
 18.OUTPUTS
 19    Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicyBuilder
 20.NOTES
 21    This function is part of the Kestrun PowerShell module and is used to configure CORS policies in
 22#>
 23function Set-KrCorsHeader {
 24    [KestrunRuntimeApi('Definition')]
 25    [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseShouldProcessForStateChangingFunctions', '')]
 26    [CmdletBinding(DefaultParameterSetName = 'With')]
 27    [OutputType([Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicyBuilder])]
 28    param(
 29        [Parameter(Mandatory, ValueFromPipeline)]
 30        [Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicyBuilder]$Builder,
 31
 32        [Parameter(Mandatory, ParameterSetName = 'Any')]
 33        [switch]$Any,
 34
 35        [Parameter(Mandatory, ParameterSetName = 'With')]
 36        [string[]]$Headers
 37    )
 38    process {
 039        if ($Any) { $Builder.AllowAnyHeader() | Out-Null }
 040        else { $Builder.WithHeaders($Headers) | Out-Null }
 041        $Builder
 42    }
 43}

Methods/Properties

Set-KrCorsHeader()