Last active
November 9, 2024 08:01
-
-
Save nguyendangminh/bd6e1e01df3c6cff139b1609fc1a646c to your computer and use it in GitHub Desktop.
Serve favicon.ico in Golang
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
func faviconHandler(w http.ResponseWriter, r *http.Request) { | |
http.ServeFile(w, r, "relative/path/to/favicon.ico") | |
} | |
... | |
func main() { | |
http.HandleFunc("/favicon.ico", faviconHandler) | |
} |
Thanks, I feel like a derp. Took me an hour to figure out why I couldn't get the favicon to show...
If there was an easier way to do this with rice... I do have the method now.
👍
thanks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Now that I see the solution, I'm embarrassed I even thought to search for it. Still, thank you for posting this.