< Summary - Kestrun — Combined Coverage

Information
Class: Public.Response.Write-KrStatusResponse
Assembly: Kestrun.PowerShell.Public
File(s): /home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Public/Response/Write-KrStatusResponse.ps1
Tag: Kestrun/Kestrun@2d87023b37eb91155071c91dd3d6a2eeb3004705
Line coverage
0%
Covered lines: 0
Uncovered lines: 3
Coverable lines: 3
Total lines: 33
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 10/13/2025 - 16:52:37 Line coverage: 0% (0/3) Total lines: 33 Tag: Kestrun/Kestrun@10d476bee71c71ad215bb8ab59f219887b5b4a5e

Metrics

File(s)

/home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Public/Response/Write-KrStatusResponse.ps1

#LineLine coverage
 1<#
 2    .SYNOPSIS
 3        Sets only the HTTP status code for the response, without a body.
 4    .DESCRIPTION
 5        Sets the HTTP status code for the response and clears any body or content type,
 6        allowing status code pages middleware to handle the response body if configured.
 7    .PARAMETER StatusCode
 8        The HTTP status code to set for the response.
 9    .EXAMPLE
 10        Write-KrStatusResponse -StatusCode 404
 11        Sets the response status code to 404 Not Found, without a body. If status code pages
 12        middleware is enabled, it will generate the response body.
 13    .NOTES
 14        This function is designed to be used in the context of a Kestrun server response.
 15#>
 16function Write-KrStatusResponse {
 17    [KestrunRuntimeApi('Route')]
 18    [CmdletBinding()]
 19    param(
 20        [Parameter(Mandatory = $true)]
 21        [int]$StatusCode
 22    )
 23
 24    # Only works inside a route script block where $Context is available
 025    if ($null -eq $Context -or $null -eq $Context.Response) {
 026        Write-KrOutsideRouteWarning
 27        return
 28    }
 29
 30    # Write only the status code, letting any status code pages middleware handle the response body
 031    $Context.Response.WriteStatusOnly($StatusCode)
 32}
 33

Methods/Properties

Write-KrStatusResponse()