icon.go 773 B

1234567891011121314151617181920212223242526272829303132333435363738
  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 api // import "miniflux.app/api"
  5. import (
  6. "net/http"
  7. "miniflux.app/http/request"
  8. "miniflux.app/http/response/json"
  9. )
  10. func (h *handler) feedIcon(w http.ResponseWriter, r *http.Request) {
  11. feedID := request.RouteInt64Param(r, "feedID")
  12. if !h.store.HasIcon(feedID) {
  13. json.NotFound(w, r)
  14. return
  15. }
  16. icon, err := h.store.IconByFeedID(request.UserID(r), feedID)
  17. if err != nil {
  18. json.ServerError(w, r, err)
  19. return
  20. }
  21. if icon == nil {
  22. json.NotFound(w, r)
  23. return
  24. }
  25. json.OK(w, r, &feedIconResponse{
  26. ID: icon.ID,
  27. MimeType: icon.MimeType,
  28. Data: icon.DataURL(),
  29. })
  30. }