1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-08-01 17:38:37 +00:00

Refactor entry validation

This commit is contained in:
Frédéric Guillot 2021-01-04 15:32:32 -08:00 committed by fguillot
parent 806b9545a9
commit 11e110bc7d
14 changed files with 192 additions and 202 deletions

View file

@ -5,10 +5,6 @@
package api // import "miniflux.app/api"
import (
"encoding/json"
"fmt"
"io"
"miniflux.app/model"
)
@ -26,19 +22,3 @@ type entriesResponse struct {
type feedCreationResponse struct {
FeedID int64 `json:"feed_id"`
}
func decodeEntryStatusRequest(r io.ReadCloser) ([]int64, string, error) {
type payload struct {
EntryIDs []int64 `json:"entry_ids"`
Status string `json:"status"`
}
var p payload
decoder := json.NewDecoder(r)
defer r.Close()
if err := decoder.Decode(&p); err != nil {
return nil, "", fmt.Errorf("invalid JSON payload: %v", err)
}
return p.EntryIDs, p.Status, nil
}