< 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@6135d944f8787fb570e4dfbacac6e80312799a86
Line coverage
0%
Covered lines: 0
Uncovered lines: 13
Coverable lines: 13
Total lines: 100
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/01/2025 - 20:55:19 Line coverage: 0% (0/4) Total lines: 48 Tag: Kestrun/Kestrun@638a27c2dd54103f693f023b6ba5f56a884caafa01/12/2026 - 18:03:06 Line coverage: 0% (0/15) Total lines: 107 Tag: Kestrun/Kestrun@956332ccc921363590dccd99d5707fb20b50966b05/09/2026 - 21:51:36 Line coverage: 0% (0/13) Total lines: 100 Tag: Kestrun/Kestrun@6b24c7512a1bad61723a28d32446de0aa658293e

Coverage delta

Coverage delta 1 -1

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 Path
 7        The URL path where the SignalR hub will be accessible. Defaults to '/hubs/kestrun'.
 8    .PARAMETER DocId
 9        The OpenAPI document IDs to which the SignalR hub endpoint should be added. Default is '
 10    .PARAMETER Summary
 11        Optional OpenAPI summary override for the SignalR hub endpoint.
 12    .PARAMETER Description
 13        Optional OpenAPI description override for the SignalR hub endpoint.
 14    .PARAMETER Tags
 15        Optional OpenAPI tags override for the SignalR hub endpoint.
 16    .PARAMETER HubName
 17        Optional name of the SignalR hub. If not provided, defaults to 'kestrun'.
 18    .PARAMETER IncludeNegotiateEndpoint
 19        If specified, includes the negotiate endpoint for the SignalR hub.
 20    .PARAMETER SkipOpenApi
 21        If specified, the OpenAPI documentation for this endpoint will be skipped.
 22    .PARAMETER Options
 23        Full OpenAPI customization object (Kestrun.Hosting.Options.SignalROpenApiOptions).
 24        When provided, it takes precedence over the individual -OpenApi* parameters.
 25    .EXAMPLE
 26        Add-KrSignalRHubMiddleware -Path '/hubs/notifications' -HubName 'NotificationsHub' -IncludeNegotiateEndpoint
 27        Adds a SignalR hub at the path '/hubs/notifications' with the hub name 'NotificationsHub' and includes the negot
 28    .EXAMPLE
 29        $options = [Kestrun.Hosting.Options.SignalROptions]::new()
 30        $options.Path = '/hubs/updates'
 31        $options.HubName = 'UpdatesHub'
 32        $options.IncludeNegotiateEndpoint = $true
 33        Add-KrSignalRHubMiddleware -Options $options
 34        Adds a SignalR hub at the path '/hubs/updates' with the hub name 'UpdatesHub' and includes the negotiate endpoin
 35    .EXAMPLE
 36        Add-KrSignalRHubMiddleware -Path '/hubs/alerts' -HubName 'AlertsHub' -SkipOpenApi
 37        Adds a SignalR hub at the path '/hubs/alerts' with the hub name 'AlertsHub' and skips OpenAPI documentation for 
 38    .NOTES
 39        This function is part of the Kestrun PowerShell module and is used to manage SignalR hubs on the Kestrun server.
 40        The Server parameter accepts a KestrunHost instance; if not provided, the default server is used.
 41        The Path parameter specifies the URL path where the SignalR hub will be accessible.
 42        The PassThru switch allows the function to return the modified server instance for further use.
 43#>
 44function Add-KrSignalRHubMiddleware {
 45    [KestrunRuntimeApi('Definition')]
 46    [CmdletBinding(DefaultParameterSetName = 'Items')]
 47    param(
 48        [Parameter(Mandatory = $false, ParameterSetName = 'Items')]
 49        [Parameter(Mandatory = $false, ParameterSetName = 'ItemsSkipOpenApi')]
 50        [string]$Path,
 51
 52        [Parameter(Mandatory = $false, ParameterSetName = 'Items')]
 53        [Parameter(Mandatory = $false, ParameterSetName = 'ItemsSkipOpenApi')]
 54        [string[]]$DocId = [Kestrun.OpenApi.OpenApiDocDescriptor]::DefaultDocumentationIds,
 55
 56        [Parameter(Mandatory = $false, ParameterSetName = 'Items')]
 57        [string]$Summary,
 58
 59        [Parameter(Mandatory = $false, ParameterSetName = 'Items')]
 60        [string]$Description,
 61
 62        [Parameter(Mandatory = $false, ParameterSetName = 'Items')]
 63        [string[]]$Tags,
 64
 65        [Parameter(Mandatory = $false, ParameterSetName = 'Items')]
 66        [string]$HubName,
 67
 68        [Parameter(Mandatory = $false, ParameterSetName = 'ItemsSkipOpenApi')]
 69        [switch]$SkipOpenApi,
 70
 71        [Parameter(Mandatory = $false, ParameterSetName = 'Items')]
 72        [switch]$IncludeNegotiateEndpoint,
 73
 74        [Parameter(Mandatory = $true, ParameterSetName = 'Options')]
 75        [Kestrun.Hosting.Options.SignalROptions]$Options
 76    )
 77    # Ensure the server instance is resolved
 078    $Server = Resolve-KestrunServer
 79
 80    # If the Options parameter set is not used, create an options object from the individual parameters
 081    if ($PSCmdlet.ParameterSetName -eq 'Items') {
 082        $Options = [Kestrun.Hosting.Options.SignalROptions]::new()
 083        if ( $SkipOpenApi.IsPresent ) {
 084            $Options.SkipOpenApi = $true
 85        }
 86        # Set the OpenAPI documentation details for the SignalR hub endpoint
 087        if ($PSBoundParameters.ContainsKey('Summary')) { $Options.Summary = $Summary }
 088        if ($PSBoundParameters.ContainsKey('Description')) { $Options.Description = $Description }
 089        if ($PSBoundParameters.ContainsKey('Tags')) { $Options.Tags = $Tags }
 090        if ($PSBoundParameters.ContainsKey('HubName')) { $Options.HubName = $HubName }
 91        # Set the documentation IDs for the SignalR hub
 092        $Options.DocId = $DocId
 93        # Set the path for the SignalR hub
 094        if ($PSBoundParameters.ContainsKey('Path')) { $Options.Path = $Path }
 095        $Options.IncludeNegotiateEndpoint = $IncludeNegotiateEndpoint.IsPresent
 96    }
 97    # Add the SignalR hub middleware to the server
 098    $server.AddSignalR($Options) | Out-Null
 99}
 100

Methods/Properties

Add-KrSignalRHubMiddleware()