< Summary - Kestrun — Combined Coverage

Information
Class: Public.Razor.Add-KrPowerShellRazorPagesRuntime
Assembly: Kestrun.PowerShell.Public
File(s): /home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Public/Razor/Add-KrPowerShellRazorPagesRuntime.ps1
Tag: Kestrun/Kestrun@9d3a582b2d63930269564a7591aa77ef297cadeb
Line coverage
0%
Covered lines: 0
Uncovered lines: 8
Coverable lines: 8
Total lines: 58
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/Razor/Add-KrPowerShellRazorPagesRuntime.ps1

#LineLine coverage
 1<#
 2    .SYNOPSIS
 3    Adds PowerShell support for Razor Pages.
 4    .DESCRIPTION
 5        This cmdlet allows you to register Razor Pages with PowerShell support in the Kestrun server.
 6        It can be used to serve dynamic web pages using Razor syntax with PowerShell code blocks.
 7    .PARAMETER Server
 8        The Kestrun server instance to which the PowerShell Razor Pages service will be added.
 9    .PARAMETER PathPrefix
 10        An optional path prefix for the Razor Pages. If specified, the Razor Pages will be served under this path.
 11    .PARAMETER PassThru
 12        If specified, the cmdlet will return the modified server instance.
 13    .EXAMPLE
 14        $server | Add-KrPowerShellRazorPagesRuntime -PathPrefix '/pages'
 15        This example adds PowerShell support for Razor Pages to the server, with a path prefix of '/pages'.
 16    .EXAMPLE
 17        $server | Add-KrPowerShellRazorPagesRuntime
 18        This example adds PowerShell support for Razor Pages to the server without a path prefix.
 19    .NOTES
 20        This cmdlet is used to register Razor Pages with PowerShell support in the Kestrun server, allowing you to serve
 21#>
 22function Add-KrPowerShellRazorPagesRuntime {
 23    [KestrunRuntimeApi('Definition')]
 24    [CmdletBinding()]
 25    [OutputType([Kestrun.Hosting.KestrunHost])]
 26    param(
 27        [Parameter(Mandatory = $false, ValueFromPipeline = $true)]
 28        [Kestrun.Hosting.KestrunHost]$Server,
 29
 30        [Parameter()]
 31        [string]$PathPrefix,
 32
 33        [Parameter()]
 34        [switch]$PassThru
 35    )
 36    begin {
 37        # Ensure the server instance is resolved
 038        $Server = Resolve-KestrunServer -Server $Server
 039        if ($null -eq $Server) {
 040            throw 'Server is not initialized. Please ensure the server is configured before setting options.'
 41        }
 42    }
 43    process {
 44
 045        if ([string]::IsNullOrWhiteSpace($PathPrefix)) {
 046            [Kestrun.Hosting.KestrunHostRazorExtensions]::AddPowerShellRazorPages($Server) | Out-Null
 47        } else {
 048            [Kestrun.Hosting.KestrunHostRazorExtensions]::AddPowerShellRazorPages($Server, [Microsoft.AspNetCore.Http.Pa
 49        }
 50
 051        if ($PassThru.IsPresent) {
 52            # if the PassThru switch is specified, return the server instance
 53            # Return the modified server instance
 054            return $Server
 55        }
 56    }
 57}
 58