feed_icon.go 712 B

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