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