static_favicon.go 818 B

1234567891011121314151617181920212223242526272829303132333435
  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. "net/http"
  7. "time"
  8. "miniflux.app/http/response"
  9. "miniflux.app/http/response/html"
  10. "miniflux.app/ui/static"
  11. )
  12. func (h *handler) showFavicon(w http.ResponseWriter, r *http.Request) {
  13. etag, err := static.GetBinaryFileChecksum("favicon.ico")
  14. if err != nil {
  15. html.NotFound(w, r)
  16. return
  17. }
  18. response.New(w, r).WithCaching(etag, 48*time.Hour, func(b *response.Builder) {
  19. blob, err := static.LoadBinaryFile("favicon.ico")
  20. if err != nil {
  21. html.ServerError(w, r, err)
  22. return
  23. }
  24. b.WithHeader("Content-Type", "image/x-icon")
  25. b.WithoutCompression()
  26. b.WithBody(blob)
  27. b.Write()
  28. })
  29. }