< Summary - Kestrun — Combined Coverage

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

#LineLine coverage
 1<#
 2    .SYNOPSIS
 3        Writes a redirect response to the HTTP client.
 4    .DESCRIPTION
 5        Sets the Location header to the provided URL and optionally includes a
 6        message body describing the redirect.
 7    .PARAMETER Url
 8        The URL to redirect the client to. This should be a fully qualified URL.
 9    .PARAMETER Message
 10        An optional message to include in the response body. This can be used to provide additional context about the re
 11    .EXAMPLE
 12        Write-KrRedirectResponse -Url "https://example.com/new-page" -Message "You are being redirected to the new page.
 13        Redirects the client to "https://example.com/new-page" and includes a message in the response body.
 14    .NOTES
 15        This function is designed to be used in the context of a Kestrun server response.
 16#>
 17function Write-KrRedirectResponse {
 18    [KestrunRuntimeApi('Route')]
 19    [CmdletBinding()]
 20    param(
 21        [Parameter(Mandatory = $true)]
 22        [string]$Url,
 23        [Parameter()]
 24        [string]$Message
 25    )
 026    if ($null -ne $Context.Response) {
 27        # Call the C# method on the $Context.Response object
 028        $Context.Response.WriteRedirectResponse($Url, $Message)
 29    }
 30}
 31

Methods/Properties

Write-KrRedirectResponse()