icon.go 731 B

123456789101112131415161718192021222324252627282930313233
  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 controller
  5. import (
  6. "time"
  7. "github.com/miniflux/miniflux/server/core"
  8. )
  9. // ShowIcon shows the feed icon.
  10. func (c *Controller) ShowIcon(ctx *core.Context, request *core.Request, response *core.Response) {
  11. iconID, err := request.IntegerParam("iconID")
  12. if err != nil {
  13. response.HTML().BadRequest(err)
  14. return
  15. }
  16. icon, err := c.store.IconByID(iconID)
  17. if err != nil {
  18. response.HTML().ServerError(err)
  19. return
  20. }
  21. if icon == nil {
  22. response.HTML().NotFound()
  23. return
  24. }
  25. response.Cache(icon.MimeType, icon.Hash, icon.Content, 72*time.Hour)
  26. }