23 lines
868 B
Go
23 lines
868 B
Go
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))
|
|
}
|