google / jsonapi

jsonapi.org style payload serializer and deserializer
http://godoc.org/github.com/google/jsonapi
MIT License
1.42k stars 210 forks source link

adding meta at time of encoding #216

Open Br3nda opened 2 years ago

Br3nda commented 2 years ago

can you help me work out how to inject the result count into the meta? i have it in an int64 in my own function

func Encode(w io.Writer, mm interface{}, resultCount int64) error {
    return jsonapi.MarshalPayload(w, mm)
}

I see I can add it to a each of my model structs as a JSONAPIMeta() but those models don't know the count of results, I don't have a way of getting the integer into those objects.

Can't I just tell the jsonapi module what to put in the meta at time of encoding?