| | 1 | | <# |
| | 2 | | .SYNOPSIS |
| | 3 | | Adds a favicon to the Kestrun server. |
| | 4 | | .DESCRIPTION |
| | 5 | | This cmdlet allows you to register a favicon for the Kestrun server. |
| | 6 | | It can be used to set a custom favicon for the server's web interface. |
| | 7 | | .PARAMETER Server |
| | 8 | | The Kestrun server instance to which the favicon will be added. |
| | 9 | | .PARAMETER IconPath |
| | 10 | | The path to the favicon file. If not specified, a default embedded favicon will be used. |
| | 11 | | .PARAMETER PassThru |
| | 12 | | If specified, returns the modified server instance after adding the favicon. |
| | 13 | | .EXAMPLE |
| | 14 | | $server | Add-KrFavicon -IconPath 'C:\path\to\favicon.ico' |
| | 15 | | This example adds a custom favicon to the server from the specified path. |
| | 16 | | .EXAMPLE |
| | 17 | | $server | Add-KrFavicon |
| | 18 | | This example adds the default embedded favicon to the server. |
| | 19 | | .NOTES |
| | 20 | | This cmdlet is used to register a favicon for the Kestrun server, allowing you to set a custom favicon for the s |
| | 21 | | If no icon path is specified, the default embedded favicon will be used. |
| | 22 | | #> |
| | 23 | | function Add-KrFavicon { |
| | 24 | | [KestrunRuntimeApi('Definition')] |
| | 25 | | [CmdletBinding()] |
| | 26 | | [OutputType([Kestrun.Hosting.KestrunHost])] |
| | 27 | | param( |
| | 28 | | [Parameter(Mandatory = $false, ValueFromPipeline = $true)] |
| | 29 | | [Kestrun.Hosting.KestrunHost]$Server, |
| | 30 | |
|
| | 31 | | [string]$IconPath = $null, |
| | 32 | |
|
| | 33 | | [Parameter()] |
| | 34 | | [switch]$PassThru |
| | 35 | | ) |
| | 36 | | begin { |
| | 37 | | # Ensure the server instance is resolved |
| 1 | 38 | | $Server = Resolve-KestrunServer -Server $Server |
| 1 | 39 | | if ($null -eq $Server) { |
| 0 | 40 | | throw 'Server is not initialized. Please ensure the server is configured before setting options.' |
| | 41 | | } |
| | 42 | | } |
| | 43 | | process { |
| 2 | 44 | | [Kestrun.Hosting.KestrunHostStaticFilesExtensions]::AddFavicon($Server, $IconPath) | Out-Null |
| | 45 | |
|
| 1 | 46 | | if ($PassThru.IsPresent) { |
| | 47 | | # if the PassThru switch is specified, return the server instance |
| | 48 | | # Return the modified server instance |
| 0 | 49 | | return $Server |
| | 50 | | } |
| | 51 | | } |
| | 52 | | } |
| | 53 | |
|