| | | 1 | | <# |
| | | 2 | | .SYNOPSIS |
| | | 3 | | Check if a specific feature is supported in the current Kestrun runtime environment. |
| | | 4 | | .DESCRIPTION |
| | | 5 | | This cmdlet checks if a given feature, identified by its name, is supported in the current Kestrun runtime environme |
| | | 6 | | It can be used to determine if certain capabilities are available based on the runtime version and configuration. |
| | | 7 | | For HTTP/3 checks, this cmdlet also verifies platform QUIC availability. |
| | | 8 | | .PARAMETER Feature |
| | | 9 | | The name of the feature to check. This can be either the name of a KnownFeature enum value or a raw string represent |
| | | 10 | | .EXAMPLE |
| | | 11 | | Test-KrCapability -Feature "Http3" |
| | | 12 | | This example checks if HTTP/3 is supported and QUIC is available on the current platform/runtime. |
| | | 13 | | .EXAMPLE |
| | | 14 | | Test-KrCapability -Feature "Quic" |
| | | 15 | | This example checks if QUIC is available using Kestrun host capability detection. |
| | | 16 | | .EXAMPLE |
| | | 17 | | Test-KrCapability -Feature "SomeOtherFeature" |
| | | 18 | | This example checks if a feature named "SomeOtherFeature" is supported, using a raw string. |
| | | 19 | | #> |
| | | 20 | | function Test-KrCapability { |
| | | 21 | | [KestrunRuntimeApi('Everywhere')] |
| | | 22 | | [CmdletBinding()] |
| | | 23 | | [OutputType([bool])] |
| | | 24 | | param( |
| | | 25 | | [Parameter(Mandatory)] |
| | | 26 | | [string]$Feature |
| | | 27 | | ) |
| | | 28 | | |
| | | 29 | | # HTTP/3 capability: relies on runtime feature support (which already checks QUIC availability) |
| | 2 | 30 | | if ($Feature -in @('Http3', 'Http3Support')) { |
| | 1 | 31 | | return [Kestrun.KestrunRuntimeInfo]::Supports('Http3') |
| | | 32 | | } |
| | | 33 | | |
| | | 34 | | # QUIC capability: reflects platform QUIC availability via Kestrun host detection |
| | 2 | 35 | | if ($Feature -in @('Quic', 'QuicSupport')) { |
| | 1 | 36 | | return [Kestrun.Hosting.KestrunHost]::IsQuicSupported() |
| | | 37 | | } |
| | | 38 | | |
| | | 39 | | # Allow either enum name or raw string |
| | | 40 | | try { |
| | 0 | 41 | | $enum = [Kestrun.KestrunRuntimeInfo+KnownFeature]::$Feature |
| | 0 | 42 | | return [Kestrun.KestrunRuntimeInfo]::Supports($enum) |
| | | 43 | | } catch [System.ArgumentException] { |
| | 0 | 44 | | return [Kestrun.KestrunRuntimeInfo]::Supports($Feature) |
| | | 45 | | } |
| | | 46 | | } |