static_favicon.go 858 B

123456789101112131415161718192021222324252627282930313233343536
  1. // Copyright 2018 Frédéric Guillot. All rights reserved.
  2. // Use of this source code is governed by the Apache 2.0
  3. // license that can be found in the LICENSE file.
  4. package ui // import "miniflux.app/ui"
  5. import (
  6. "encoding/base64"
  7. "net/http"
  8. "time"
  9. "miniflux.app/http/response"
  10. "miniflux.app/http/response/html"
  11. "miniflux.app/ui/static"
  12. )
  13. func (h *handler) showFavicon(w http.ResponseWriter, r *http.Request) {
  14. etag, found := static.BinariesChecksums["favicon.ico"]
  15. if !found {
  16. html.NotFound(w, r)
  17. return
  18. }
  19. response.New(w, r).WithCaching(etag, 48*time.Hour, func(b *response.Builder) {
  20. blob, err := base64.StdEncoding.DecodeString(static.Binaries["favicon.ico"])
  21. if err != nil {
  22. html.ServerError(w, r, err)
  23. return
  24. }
  25. b.WithHeader("Content-Type", "image/x-icon")
  26. b.WithoutCompression()
  27. b.WithBody(blob)
  28. b.Write()
  29. })
  30. }