mirror of
https://github.com/balzack/databag.git
synced 2025-02-14 12:39:17 +00:00
returning revision in header
This commit is contained in:
parent
7f625cd9bc
commit
7a001a4075
@ -48,6 +48,8 @@ func GetArticles(w http.ResponseWriter, r *http.Request) {
|
||||
for _, article := range articles {
|
||||
response = append(response, getArticleModel(&article, false, true))
|
||||
}
|
||||
|
||||
w.Header().Set("Content-Revision", strconv.FormatInt(account.ContentRevision, 10))
|
||||
} else if tokenType == APP_TOKENCONTACT {
|
||||
|
||||
card, code, err := BearerContactToken(r, false)
|
||||
@ -60,8 +62,6 @@ func GetArticles(w http.ResponseWriter, r *http.Request) {
|
||||
if revisionSet {
|
||||
ErrResponse(w, http.StatusGone, errors.New("article view unavailable"))
|
||||
return
|
||||
} else {
|
||||
w.Header().Set("View-Revision", strconv.FormatInt(card.ViewRevision + card.Account.ViewRevision, 10))
|
||||
}
|
||||
}
|
||||
|
||||
@ -78,6 +78,9 @@ func GetArticles(w http.ResponseWriter, r *http.Request) {
|
||||
response = append(response, getArticleModel(&article, true, false))
|
||||
}
|
||||
}
|
||||
|
||||
w.Header().Set("View-Revision", strconv.FormatInt(card.ViewRevision + card.Account.ViewRevision, 10))
|
||||
w.Header().Set("Content-Revision", strconv.FormatInt(card.Account.ContentRevision, 10))
|
||||
} else {
|
||||
ErrResponse(w, http.StatusBadRequest, errors.New("invalid token type"))
|
||||
}
|
||||
|
@ -34,5 +34,7 @@ func GetCards(w http.ResponseWriter, r *http.Request) {
|
||||
for _, slot := range slots {
|
||||
response = append(response, getCardModel(&slot))
|
||||
}
|
||||
|
||||
w.Header().Set("Card-Revision", strconv.FormatInt(account.CardRevision, 10))
|
||||
WriteResponse(w, response)
|
||||
}
|
||||
|
@ -34,6 +34,8 @@ func GetGroups(w http.ResponseWriter, r *http.Request) {
|
||||
for _, slot := range slots {
|
||||
groups = append(groups, getGroupModel(&slot))
|
||||
}
|
||||
|
||||
w.Header().Set("Group-Revision", strconv.FormatInt(account.GroupRevision, 10))
|
||||
WriteResponse(w, groups)
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestAddContact(t *testing.T) {
|
||||
func TestUpdateContact(t *testing.T) {
|
||||
var err error
|
||||
var set *TestGroup
|
||||
var rev *Revision
|
Loading…
Reference in New Issue
Block a user