< Summary - Kestrun — Combined Coverage

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

Metrics

File(s)

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

#LineLine coverage
 1<#
 2    .SYNOPSIS
 3        Writes CSV data to the HTTP response body.
 4    .DESCRIPTION
 5        Sends a raw CSV payload to the client and optionally sets the HTTP status
 6        code and content type.
 7    .PARAMETER InputObject
 8        The CSV content to write to the response body. This can be a string or any
 9        other object that can be converted to a string.
 10    .PARAMETER StatusCode
 11        The HTTP status code to set for the response. Defaults to 200 (OK).
 12    .PARAMETER ContentType
 13        The content type of the response. If not specified, defaults to "text/csv".
 14    .PARAMETER CsvConfiguration
 15        An optional CsvHelper configuration object to customize CSV serialization.
 16    .EXAMPLE
 17        Write-KrCsvResponse -InputObject "Name,Age`nAlice,30`nBob,25" -StatusCode 200
 18        Writes the CSV data to the response body with a 200 OK status code.
 19    .NOTES
 20        This function is designed to be used in the context of a Kestrun server response.
 21#>
 22function Write-KrCsvResponse {
 23    [KestrunRuntimeApi('Route')]
 24    [CmdletBinding()]
 25    param(
 26        [Parameter(Mandatory = $true)]
 27        [object]$InputObject,
 28        [Parameter()]
 29        [int]$StatusCode = 200,
 30        [Parameter()]
 31        [string]$ContentType,
 32        [Parameter()]
 33        [CsvHelper.Configuration.CsvConfiguration] $CsvConfiguration = $null
 34    )
 035    if ($null -ne $Context.Response) {
 036        $Context.Response.WriteCsvResponse($InputObject, $StatusCode, $ContentType, $CsvConfiguration)
 37    }
 38}
 39

Methods/Properties

Write-KrCsvResponse()