-
-
Notifications
You must be signed in to change notification settings - Fork 95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for Custom and default Favicons in Pode Endpoints #1509
base: develop
Are you sure you want to change the base?
Conversation
src/Public/Endpoint.ps1
Outdated
|
||
# If no -Favicon is provided, the protocol is either HTTP or HTTPS, and -DefaultFavicon is enabled, | ||
# set the default favicon from the Pode module's miscellaneous path. | ||
if ( ($null -eq $Favicon) -and (@('Http', 'Https') -icontains $Protocol) -and $DefaultFavicon) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We wouldn't need to check ($null -eq $Favicon)
at this point, as we know it will be null/empty if $DefaultFavicon
is true.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why? I can call add-podeEndpoint with both -Favicon adn -DefaultFavicon.
I can create an new parameterset but start to become complicated with all these parameters
- ContentType is matching the image type - Favicon parameter can be a path or a byte array - Documentation improvements
I was having a think about this yesterday, and I'm wondering if it's actually better to separate the Favicon logic away from Endpoint. Separating it out into it's own This helps keep the Endpoint functions tidier, but also lets us more easily extend Favicon support in the future if we need to. As for where the favicon selector logic runs, currently is directly in the PodeServer.ps1 scriptblock. I'm thinking this would be better either in the This would also mean you could have different Ie: # load file and read in bytes
Add-PodeFavicon
-Path [string]
-EndpointName [string]
-Route [string]
# has bytes directly supplied for custom cases
Add-PodeFavicon
-Binary [byte[]]
-EndpointName [string]
-Route [string]
# use the internal default favicon
Add-PodeFavicon
-Default [switch]
-EndpointName [string]
-Route [string] EndpointName/Route could be Additional functions:
In terms of the fitlering/priority for selecting the favicon, if the request is
|
Personally, I believe using middleware to serve the favicon is overkill. The favicon should be served as early as possible—ideally, directly from the C# code—before any route or path processing occurs. This approach aligns with the RFC guidelines, which imply that the favicon should be returned regardless of any security measures or routing rules applied to other endpoints. |
Overview
This PR introduces two new parameters to
Add-PodeEndpoint
, allowing greater control over favicon handling in HTTP/HTTPS endpoints.Changes
-Favicon
(byte[]): Allows specifying a custom favicon for an endpoint.-DefaultFavicon
(switch): Enable the default Pode favicon for HTTP/HTTPS endpoints.Usage Examples
For more details on favicon formats and specifications, refer to the Favicon specification and RFC 5988.