Add favicon
This commit is contained in:
parent
1509789cde
commit
2852be0a87
3 changed files with 30 additions and 1 deletions
23
internal/server/favicon.go
Normal file
23
internal/server/favicon.go
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
package server
|
||||
|
||||
import "net/http"
|
||||
|
||||
const faviconSVG = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
|
||||
<rect width="64" height="64" rx="5" fill="#111111"/>
|
||||
<text x="32" y="35" text-anchor="middle" font-family="ui-monospace, Menlo, Consolas, monospace" font-size="19" font-weight="700" fill="#2ecc71">Rud?</text>
|
||||
<rect x="10" y="40" width="45" height="5" rx="1.5" fill="#2ecc71"/>
|
||||
</svg>`
|
||||
|
||||
func (s *Server) serveFavicon(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Method != http.MethodGet && r.Method != http.MethodHead {
|
||||
w.Header().Set("Allow", "GET, HEAD")
|
||||
http.Error(w, "method not allowed", http.StatusMethodNotAllowed)
|
||||
return
|
||||
}
|
||||
w.Header().Set("Content-Type", "image/svg+xml; charset=utf-8")
|
||||
w.Header().Set("Cache-Control", "public, max-age=86400")
|
||||
if r.Method == http.MethodHead {
|
||||
return
|
||||
}
|
||||
_, _ = w.Write([]byte(faviconSVG))
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue