< Summary - Kestrun — Combined Coverage

Information
Class: Public.Middleware.Add-KrSignalRHubMiddleware
Assembly: Kestrun.PowerShell.Public
File(s): /home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Public/Middleware/Add-KrSignalRHubMiddleware.ps1
Tag: Kestrun/Kestrun@ca54e35c77799b76774b3805b6f075cdbc0c5fbe
Line coverage
0%
Covered lines: 0
Uncovered lines: 15
Coverable lines: 15
Total lines: 107
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 09/13/2025 - 17:19:56 Line coverage: 0% (0/13) Total lines: 87 Tag: Kestrun/Kestrun@ea635f1ee1937c260a89d1a43a3c203cd8767c7b10/13/2025 - 16:52:37 Line coverage: 0% (0/11) Total lines: 83 Tag: Kestrun/Kestrun@10d476bee71c71ad215bb8ab59f219887b5b4a5e10/15/2025 - 21:27:26 Line coverage: 0% (0/4) Total lines: 48 Tag: Kestrun/Kestrun@c33ec02a85e4f8d6061aeaab5a5e8c3a8b66559401/12/2026 - 18:03:06 Line coverage: 0% (0/15) Total lines: 107 Tag: Kestrun/Kestrun@956332ccc921363590dccd99d5707fb20b50966b

Metrics

File(s)

/home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Public/Middleware/Add-KrSignalRHubMiddleware.ps1

#LineLine coverage
 1<#
 2    .SYNOPSIS
 3        Maps a SignalR hub class to the given URL path.
 4    .DESCRIPTION
 5        This function allows you to map a SignalR hub class to a specific URL path on the Kestrun server.
 6    .PARAMETER Server
 7        The Kestrun server instance to which the SignalR hub will be added.
 8    .PARAMETER Path
 9        The URL path where the SignalR hub will be accessible. Defaults to '/hubs/kestrun'.
 10    .PARAMETER DocId
 11        The OpenAPI document IDs to which the SignalR hub endpoint should be added. Default is '
 12    .PARAMETER Summary
 13        Optional OpenAPI summary override for the SignalR hub endpoint.
 14    .PARAMETER Description
 15        Optional OpenAPI description override for the SignalR hub endpoint.
 16    .PARAMETER Tags
 17        Optional OpenAPI tags override for the SignalR hub endpoint.
 18    .PARAMETER HubName
 19        Optional name of the SignalR hub. If not provided, defaults to 'kestrun'.
 20    .PARAMETER IncludeNegotiateEndpoint
 21        If specified, includes the negotiate endpoint for the SignalR hub.
 22    .PARAMETER SkipOpenApi
 23        If specified, the OpenAPI documentation for this endpoint will be skipped.
 24    .PARAMETER Options
 25        Full OpenAPI customization object (Kestrun.Hosting.Options.SignalROpenApiOptions).
 26        When provided, it takes precedence over the individual -OpenApi* parameters.
 27    .PARAMETER PassThru
 28        If specified, the cmdlet will return the modified server instance after adding the SignalR hub.
 29    .EXAMPLE
 30        Add-KrSignalRHubMiddleware -Path '/hubs/notifications' -PassThru
 31        Adds a SignalR hub at the path '/hubs/notifications' and returns the modified server instance.
 32    .NOTES
 33        This function is part of the Kestrun PowerShell module and is used to manage SignalR hubs on the Kestrun server.
 34        The Server parameter accepts a KestrunHost instance; if not provided, the default server is used.
 35        The Path parameter specifies the URL path where the SignalR hub will be accessible.
 36        The PassThru switch allows the function to return the modified server instance for further use.
 37#>
 38function Add-KrSignalRHubMiddleware {
 39    [KestrunRuntimeApi('Definition')]
 40    [CmdletBinding(DefaultParameterSetName = 'Items')]
 41    param(
 42        [Parameter(ValueFromPipeline)]
 43        [Kestrun.Hosting.KestrunHost]$Server,
 44
 45        [Parameter(Mandatory = $false, ParameterSetName = 'Items')]
 46        [Parameter(Mandatory = $false, ParameterSetName = 'ItemsSkipOpenApi')]
 47        [string]$Path,
 48
 49        [Parameter(Mandatory = $false, ParameterSetName = 'Items')]
 50        [Parameter(Mandatory = $false, ParameterSetName = 'ItemsSkipOpenApi')]
 51        [string[]]$DocId = [Kestrun.OpenApi.OpenApiDocDescriptor]::DefaultDocumentationIds,
 52
 53        [Parameter(Mandatory = $false, ParameterSetName = 'Items')]
 54        [string]$Summary,
 55
 56        [Parameter(Mandatory = $false, ParameterSetName = 'Items')]
 57        [string]$Description,
 58
 59        [Parameter(Mandatory = $false, ParameterSetName = 'Items')]
 60        [string[]]$Tags,
 61
 62        [Parameter(Mandatory = $false, ParameterSetName = 'Items')]
 63        [string]$HubName,
 64
 65        [Parameter(Mandatory = $false, ParameterSetName = 'ItemsSkipOpenApi')]
 66        [switch]$SkipOpenApi,
 67
 68        [Parameter(Mandatory = $false, ParameterSetName = 'Items')]
 69        [switch]$IncludeNegotiateEndpoint,
 70
 71        [Parameter(Mandatory = $true, ParameterSetName = 'Options')]
 72        [Kestrun.Hosting.Options.SignalROptions]$Options,
 73
 74        [Parameter()]
 75        [switch]$PassThru
 76    )
 77    begin {
 78        # Ensure the server instance is resolved
 079        $Server = Resolve-KestrunServer -Server $Server
 80    }
 81    process {
 82
 083        if ($PSCmdlet.ParameterSetName -eq 'Items') {
 084            $Options = [Kestrun.Hosting.Options.SignalROptions]::new()
 085            if ( $SkipOpenApi.IsPresent ) {
 086                $Options.SkipOpenApi = $true
 87            }
 88
 089            if ($PSBoundParameters.ContainsKey('Summary')) { $Options.Summary = $Summary }
 090            if ($PSBoundParameters.ContainsKey('Description')) { $Options.Description = $Description }
 091            if ($PSBoundParameters.ContainsKey('Tags')) { $Options.Tags = $Tags }
 092            if ($PSBoundParameters.ContainsKey('HubName')) { $Options.HubName = $HubName }
 93            # Set the documentation IDs for the SignalR hub
 094            $Options.DocId = $DocId
 95            # Set the path for the SignalR hub
 096            if ($PSBoundParameters.ContainsKey('Path')) { $Options.Path = $Path }
 097            $Options.IncludeNegotiateEndpoint = $IncludeNegotiateEndpoint.IsPresent
 98        }
 099        $server.AddSignalR($Options) | Out-Null
 100
 0101        if ($PassThru.IsPresent) {
 102            # if the PassThru switch is specified, return the modified server instance
 0103            return $Server
 104        }
 105    }
 106}
 107

Methods/Properties

Add-KrSignalRHubMiddleware()