< 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@2d87023b37eb91155071c91dd3d6a2eeb3004705
Line coverage
0%
Covered lines: 0
Uncovered lines: 3
Coverable lines: 3
Total lines: 37
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 08/26/2025 - 01:25:22 Line coverage: 0% (0/2) Total lines: 32 Tag: Kestrun/Kestrun@07f821172e5dc3657f1be7e6818f18d6721cf38a09/12/2025 - 03:43:11 Line coverage: 0% (0/3) Total lines: 35 Tag: Kestrun/Kestrun@d160286e3020330b1eb862d66a37db2e26fc904209/16/2025 - 16:28:42 Line coverage: 0% (0/3) Total lines: 37 Tag: Kestrun/Kestrun@d5c0d6132e97ca542441289c02a4c9e9d0364d49

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    # Only works inside a route script block where $Context is available
 030    if ($null -ne $Context.Response) {
 31        # Call the C# method on the $Context.Response object
 032        $Context.Response.WriteResponse($InputObject, $StatusCode)
 33    } else {
 034        Write-KrOutsideRouteWarning
 35    }
 36}
 37

Methods/Properties

Write-KrResponse()