< Summary - Kestrun — Combined Coverage

Information
Class: Public.Middleware.Cors.Set-KrCorsMethod
Assembly: Kestrun.PowerShell.Public
File(s): /home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Public/Middleware/Cors/Set-KrCorsMethod.ps1
Tag: Kestrun/Kestrun@0d738bf294e6281b936d031e1979d928007495ff
Line coverage
0%
Covered lines: 0
Uncovered lines: 3
Coverable lines: 3
Total lines: 39
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: 39 Tag: Kestrun/Kestrun@a05ac8de57c6207e227b92ba360e9d58869ac80a

Metrics

File(s)

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

#LineLine coverage
 1<#
 2.SYNOPSIS
 3    Sets the methods for a CORS policy in a .NET Core application.
 4.DESCRIPTION
 5    This function sets the methods for a CORS policy in a .NET Core application. It takes a `CorsPolicyBuilder` object a
 6.PARAMETER Builder
 7    The `CorsPolicyBuilder` object to configure.
 8.PARAMETER Any
 9    If specified, allows any HTTP method in the CORS policy.
 10.PARAMETER Methods
 11    A list of HTTP methods to allow in the CORS policy.
 12.EXAMPLE
 13    New-KrCorsPolicyBuilder | Set-KrCorsMethod -Any
 14.EXAMPLE
 15    New-KrCorsPolicyBuilder | Set-KrCorsMethod -Methods @('GET', 'POST', 'PUT', 'DELETE')
 16.OUTPUTS
 17    Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicyBuilder
 18#>
 19function Set-KrCorsMethod {
 20    [KestrunRuntimeApi('Definition')]
 21    [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseShouldProcessForStateChangingFunctions', '')]
 22    [CmdletBinding(DefaultParameterSetName = 'With')]
 23    [OutputType([Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicyBuilder])]
 24    param(
 25        [Parameter(Mandatory, ValueFromPipeline)]
 26        [Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicyBuilder]$Builder,
 27
 28        [Parameter(Mandatory, ParameterSetName = 'Any')]
 29        [switch]$Any,
 30
 31        [Parameter(Mandatory, ParameterSetName = 'With')]
 32        [string[]]$Methods
 33    )
 34    process {
 035        if ($Any) { $Builder.AllowAnyMethod() | Out-Null }
 036        else { $Builder.WithMethods($Methods) | Out-Null }
 037        return $Builder
 38    }
 39}

Methods/Properties

Set-KrCorsMethod()