< Summary - Kestrun — Combined Coverage

Information
Class: Public.Response.Write-KrTextResponse
Assembly: Kestrun.PowerShell.Public
File(s): /home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Public/Response/Write-KrTextResponse.ps1
Tag: Kestrun/Kestrun@9d3a582b2d63930269564a7591aa77ef297cadeb
Line coverage
0%
Covered lines: 0
Uncovered lines: 2
Coverable lines: 2
Total lines: 43
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

Metrics

File(s)

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

#LineLine coverage
 1<#
 2    .SYNOPSIS
 3        Writes plain text to the HTTP response body.
 4
 5    .DESCRIPTION
 6        Sends a raw text payload to the client and optionally sets the HTTP status
 7        code and content type.
 8
 9    .PARAMETER InputObject
 10        The text content to write to the response body. This can be a string or any
 11        other object that can be converted to a string.
 12
 13    .PARAMETER StatusCode
 14        The HTTP status code to set for the response. Defaults to 200 (OK).
 15
 16    .PARAMETER ContentType
 17        The content type of the response. If not specified, defaults to "text/plain".
 18
 19    .EXAMPLE
 20        Write-KrTextResponse -InputObject "Hello, World!" -StatusCode 200
 21        Writes "Hello, World!" to the response body with a 200 OK status code.
 22
 23    .NOTES
 24        This function is designed to be used in the context of a Kestrun server response.
 25#>
 26function Write-KrTextResponse {
 27    [KestrunRuntimeApi('Route')]
 28    [CmdletBinding()]
 29    param(
 30        [Parameter(Mandatory = $true)]
 31        [Alias('Text')]
 32        [object]$InputObject,
 33        [Parameter()]
 34        [int]$StatusCode = 200,
 35        [Parameter()]
 36        [string]$ContentType
 37    )
 038    if ($null -ne $Context.Response) {
 39        # Call the C# method on the $Context.Response object
 040        $Context.Response.WriteTextResponse($InputObject, $StatusCode, $ContentType)
 41    }
 42}
 43

Methods/Properties

Write-KrTextResponse()