< Summary - Kestrun — Combined Coverage

Information
Class: Public.Response.Write-KrResponse
Assembly: Kestrun.PowerShell.Public
File(s): /home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Public/Response/Write-KrResponse.ps1
Tag: Kestrun/Kestrun@eeafbe813231ed23417e7b339e170e307b2c86f9
Line coverage
0%
Covered lines: 0
Uncovered lines: 4
Coverable lines: 4
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 09/12/2025 - 13:32:05 Line coverage: 0% (0/3) Total lines: 35 Tag: Kestrun/Kestrun@63ea5841fe73fd164406accba17a956e8c08357f09/16/2025 - 16:28:42 Line coverage: 0% (0/3) Total lines: 37 Tag: Kestrun/Kestrun@d5c0d6132e97ca542441289c02a4c9e9d0364d4902/18/2026 - 08:33:07 Line coverage: 0% (0/4) Total lines: 39 Tag: Kestrun/Kestrun@bf8a937cfb7e8936c225b9df4608f8ddd85558b1

Coverage delta

Coverage delta 1 -1

Metrics

File(s)

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

#LineLine coverage
 1<#
 2    .SYNOPSIS
 3        Writes a response with the specified input object and HTTP status code.
 4    .DESCRIPTION
 5        This function is a wrapper around the Kestrun server response methods.
 6        The response format based on the Accept header or defaults to text/plain.
 7        Content type is determined automatically.
 8    .PARAMETER InputObject
 9        The input object to write to the response body.
 10    .PARAMETER StatusCode
 11        The HTTP status code to set for the response. Defaults to 200 (OK).
 12
 13    .EXAMPLE
 14        Write-KrResponse -InputObject $myObject -StatusCode 200
 15        Writes the $myObject to the response with a 200 status code. The content type
 16        is determined automatically based on the Accept header or defaults to text/plain.
 17    .NOTES
 18        This function is designed to be used in the context of a Kestrun server response.
 19#>
 20function Write-KrResponse {
 21    [KestrunRuntimeApi('Route')]
 22    [CmdletBinding()]
 23    param(
 24        [Parameter(Mandatory = $true)]
 25        [object]$InputObject,
 26        [Parameter()]
 27        [int]$StatusCode = 200
 28    )
 29
 30    # Only works inside a route script block where $Context is available
 031    if ($null -ne $Context.Response) {
 032        Write-KrLog -Level Debug -Message "Write-KrResponse invoked for status code {statusCode}. Input type: {inputType
 33
 034        $Context.Response.QueueResponseForWrite($InputObject, $StatusCode)
 35    } else {
 036        Write-KrOutsideRouteWarning
 37    }
 38}
 39

Methods/Properties

Write-KrResponse()