| 596 | } |
| 597 | |
| 598 | func (h *handler) readChangesOptionsFromJSON(jsonData []byte) (feed string, options db.ChangesOptions, filter string, channelsArray []string, docIdsArray []string, compress bool, err error) { |
| 599 | var input struct { |
| 600 | Feed string `json:"feed"` |
| 601 | Since db.SequenceID `json:"since"` |
| 602 | Limit int `json:"limit"` |
| 603 | Style string `json:"style"` |
| 604 | IncludeDocs bool `json:"include_docs"` |
| 605 | Filter string `json:"filter"` |
| 606 | Channels string `json:"channels"` // a filter query param, so it has to be a string |
| 607 | DocIds []string `json:"doc_ids"` |
| 608 | HeartbeatMs *uint64 `json:"heartbeat"` |
| 609 | TimeoutMs *uint64 `json:"timeout"` |
| 610 | AcceptEncoding string `json:"accept_encoding"` |
| 611 | ActiveOnly bool `json:"active_only"` // Return active revisions only |
| 612 | RequestPlus *bool `json:"request_plus"` // Wait for sequence buffering to catch up to database seq value at time request was issued |
| 613 | VersionType string `json:"version_type"` // Version type to use for changes feed |
| 614 | } |
| 615 | |
| 616 | // Initialize since clock and hasher ahead of unmarshalling sequence |
| 617 | if h.db != nil { |
| 618 | input.Since = db.CreateZeroSinceValue() |
| 619 | } |
| 620 | |
| 621 | if err = base.JSONUnmarshal(jsonData, &input); err != nil { |
| 622 | return |
| 623 | } |
| 624 | feed = input.Feed |
| 625 | options.Since = input.Since |
| 626 | options.Limit = input.Limit |
| 627 | |
| 628 | options.Conflicts = input.Style == "all_docs" |
| 629 | options.ActiveOnly = input.ActiveOnly |
| 630 | |
| 631 | options.IncludeDocs = input.IncludeDocs |
| 632 | filter = input.Filter |
| 633 | |
| 634 | if input.Channels != "" { |
| 635 | channelsArray = strings.Split(input.Channels, ",") |
| 636 | } |
| 637 | |
| 638 | docIdsArray = input.DocIds |
| 639 | options.HeartbeatMs = base.GetRestrictedInt( |
| 640 | input.HeartbeatMs, |
| 641 | kDefaultHeartbeatMS, |
| 642 | kMinHeartbeatMS, |
| 643 | uint64(h.server.Config.Replicator.MaxHeartbeat.Value().Milliseconds()), |
| 644 | true, |
| 645 | ) |
| 646 | |
| 647 | options.TimeoutMs = base.GetRestrictedInt( |
| 648 | input.TimeoutMs, |
| 649 | kDefaultTimeoutMS, |
| 650 | 0, |
| 651 | kMaxTimeoutMS, |
| 652 | true, |
| 653 | ) |
| 654 | |
| 655 | options.VersionType, err = db.ParseChangesVersionType(input.VersionType) |