< Summary - Kestrun — Combined Coverage

Information
Class: Public.Route.Test-KrRoute
Assembly: Kestrun.PowerShell.Public
File(s): /home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Public/Route/Test-KrRoute.ps1
Tag: Kestrun/Kestrun@9d3a582b2d63930269564a7591aa77ef297cadeb
Line coverage
60%
Covered lines: 3
Uncovered lines: 2
Coverable lines: 5
Total lines: 39
Line coverage: 60%
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/Route/Test-KrRoute.ps1

#LineLine coverage
 1<#
 2    .SYNOPSIS
 3        Tests if a route exists in the Kestrun host.
 4    .DESCRIPTION
 5        This function checks if a specific route is defined in the Kestrun host's routing table.
 6    .PARAMETER Pattern
 7        The path of the route to test.
 8    .PARAMETER Verbs
 9        The HTTP verb(s) to test for the route.
 10    .EXAMPLE
 11        Test-KrRoute -Path "/api/test" -Verbs "GET"
 12        # Tests if a GET route exists for "/api/test".
 13    .EXAMPLE
 14        Test-KrRoute -Path "/api/test" -Verbs "POST"
 15        # Tests if a POST route exists for "/api/test".
 16    .NOTES
 17        This function is part of the Kestrun PowerShell module and is used to manage routes.
 18#>
 19function Test-KrRoute {
 20    [KestrunRuntimeApi('Everywhere')]
 21    [CmdletBinding()]
 22    [OutputType([bool])]
 23    param(
 24        [Parameter(Mandatory)]
 25        [alias('Path')]
 26        [string]$Pattern,
 27
 28        [Parameter()]
 029        [Kestrun.Utilities.HttpVerb[]]$Verbs = @([Kestrun.Utilities.HttpVerb]::Get)
 30    )
 31    # Ensure the server instance is resolved
 132    $Server = Resolve-KestrunServer -Server $Server
 133    if ($null -eq $Server) {
 034        throw 'Server is not initialized. Please ensure the server is configured before setting options.'
 35    }
 36
 137    return [Kestrun.Hosting.KestrunHostMapExtensions]::MapExists($Server, $Pattern, $Verbs)
 38}
 39

Methods/Properties

Test-KrRoute()