< Summary - Kestrun — Combined Coverage

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

Metrics

File(s)

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

#LineLine coverage
 1<#
 2.SYNOPSIS
 3    Sets the preflight max age for CORS policies in ASP.NET Core.
 4.DESCRIPTION
 5    This function sets the preflight max age for CORS policies in ASP.NET Core.
 6    It takes a CorsPolicyBuilder object and a TimeSpan object as input parameters.
 7    The SetPreflightMaxAge method of the CorsPolicyBuilder object is called with the provided TimeSpan object to set the
 8    The modified CorsPolicyBuilder object is then returned.
 9.PARAMETER Builder
 10    The CorsPolicyBuilder object to set the preflight max age for.
 11.PARAMETER MaxAge
 12    The TimeSpan object representing the preflight max age to set.
 13.PARAMETER Seconds
 14    The number of seconds representing the preflight max age to set.
 15.EXAMPLE
 16    New-KrCorsPolicyBuilder | Set-KrCorsPreflightMaxAge -MaxAge (New-TimeSpan -Hours 24) | Add-KrCorsPolicy -Server $ser
 17.EXAMPLE
 18    New-KrCorsPolicyBuilder | Set-KrCorsPreflightMaxAge -Seconds 86400 | Add-KrCorsPolicy -Name 'MyCORSPolicy'
 19.OUTPUTS
 20    Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicyBuilder
 21#>
 22function Set-KrCorsPreflightMaxAge {
 23    [KestrunRuntimeApi('Definition')]
 24    [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseShouldProcessForStateChangingFunctions', '')]
 25    [CmdletBinding(DefaultParameterSetName = 'TimeSpan')]
 26    [OutputType([Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicyBuilder])]
 27    param(
 28        [Parameter(Mandatory, ValueFromPipeline)]
 29        [Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicyBuilder]$Builder,
 30
 31        [Parameter(Mandatory = $true, ParameterSetName = 'TimeSpan')]
 32        [TimeSpan]$MaxAge,
 33
 34        [Parameter(Mandatory = $true, ParameterSetName = 'Seconds')]
 35        [int]$Seconds
 36    )
 37    process {
 038        if ($PSCmdlet.ParameterSetName -eq 'Seconds') {
 039            $MaxAge = New-TimeSpan -Seconds $Seconds
 40        }
 041        $Builder.SetPreflightMaxAge($MaxAge) | Out-Null
 042        $Builder
 43    }
 44}

Methods/Properties

Set-KrCorsPreflightMaxAge()