feed_icon.go 785 B

123456789101112131415161718192021222324252627282930313233343536
  1. // Copyright 2017 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
  5. import (
  6. "net/http"
  7. "time"
  8. "github.com/miniflux/miniflux/http/request"
  9. "github.com/miniflux/miniflux/http/response"
  10. "github.com/miniflux/miniflux/http/response/html"
  11. )
  12. // ShowIcon shows the feed icon.
  13. func (c *Controller) ShowIcon(w http.ResponseWriter, r *http.Request) {
  14. iconID, err := request.IntParam(r, "iconID")
  15. if err != nil {
  16. html.BadRequest(w, err)
  17. return
  18. }
  19. icon, err := c.store.IconByID(iconID)
  20. if err != nil {
  21. html.ServerError(w, err)
  22. return
  23. }
  24. if icon == nil {
  25. html.NotFound(w)
  26. return
  27. }
  28. response.Cache(w, r, icon.MimeType, icon.Hash, icon.Content, 72*time.Hour)
  29. }