payload.go 967 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. "encoding/json"
  7. "fmt"
  8. "io"
  9. "miniflux.app/model"
  10. )
  11. type feedIconResponse struct {
  12. ID int64 `json:"id"`
  13. MimeType string `json:"mime_type"`
  14. Data string `json:"data"`
  15. }
  16. type entriesResponse struct {
  17. Total int `json:"total"`
  18. Entries model.Entries `json:"entries"`
  19. }
  20. type feedCreationResponse struct {
  21. FeedID int64 `json:"feed_id"`
  22. }
  23. func decodeEntryStatusRequest(r io.ReadCloser) ([]int64, string, error) {
  24. type payload struct {
  25. EntryIDs []int64 `json:"entry_ids"`
  26. Status string `json:"status"`
  27. }
  28. var p payload
  29. decoder := json.NewDecoder(r)
  30. defer r.Close()
  31. if err := decoder.Decode(&p); err != nil {
  32. return nil, "", fmt.Errorf("invalid JSON payload: %v", err)
  33. }
  34. return p.EntryIDs, p.Status, nil
  35. }