< Summary - Kestrun — Combined Coverage

Information
Class: Public.Response.Write-KrFormUrlEncodedResponse
Assembly: Kestrun.PowerShell.Public
File(s): /home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Public/Response/Write-KrFormUrlEncodedResponse.ps1
Tag: Kestrun/Kestrun@0d738bf294e6281b936d031e1979d928007495ff
Line coverage
0%
Covered lines: 0
Uncovered lines: 6
Coverable lines: 6
Total lines: 47
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 12/12/2025 - 17:27:19 Line coverage: 0% (0/6) Total lines: 47 Tag: Kestrun/Kestrun@826bf9dcf9db118c5de4c78a3259bce9549f0dcd

Metrics

File(s)

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

#LineLine coverage
 1<#
 2    .SYNOPSIS
 3        Writes key/value data to the HTTP response body as application/x-www-form-urlencoded.
 4    .DESCRIPTION
 5        Uses the ASP.NET Core built-in System.Net.Http.FormUrlEncodedContent encoder
 6        to convert the provided object into an application/x-www-form-urlencoded
 7        payload, then writes it to the HTTP response.
 8    .PARAMETER InputObject
 9        Hashtable, PSCustomObject, dictionary, or any object with public properties.
 10    .PARAMETER StatusCode
 11        HTTP status code for the response.
 12    .PARAMETER ContentType
 13        Defaults to 'application/x-www-form-urlencoded'.
 14    .EXAMPLE
 15        @{ user='alice'; role='admin' } | Write-KrFormUrlEncodedResponse
 16#>
 17function Write-KrFormUrlEncodedResponse {
 18    [KestrunRuntimeApi('Route')]
 19    [CmdletBinding()]
 20    param(
 21        [Parameter(Mandatory = $true, ValueFromPipeline = $true)]
 22        [object]$InputObject,
 23
 24        [Parameter()]
 25        [int]$StatusCode = 200
 26    )
 27
 28    begin {
 029        $items = [System.Collections.Generic.List[object]]::new()
 30    }
 31
 32    process {
 033        $items.Add($InputObject)
 34    }
 35
 36    end {
 037        if ($null -eq $Context -or $null -eq $Context.Response) {
 038            Write-KrOutsideRouteWarning
 39            return
 40        }
 41
 042        $payload = if ($items.Count -eq 1) { $items[0] } else { $items }
 43
 44        # Call the C# method directly with arguments
 045        $Context.Response.WriteFormUrlEncodedResponse($payload, $StatusCode)
 46    }
 47}