forked from Mirrors/jsonapi
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
f0b268e046
20
response.go
20
response.go
|
@ -84,7 +84,25 @@ func Marshal(models interface{}) (Payloader, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return marshalMany(m)
|
|
||||||
|
payload, err := marshalMany(m)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if linkableModels, isLinkable := models.(Linkable); isLinkable {
|
||||||
|
jl := linkableModels.JSONAPILinks()
|
||||||
|
if er := jl.validate(); er != nil {
|
||||||
|
return nil, er
|
||||||
|
}
|
||||||
|
payload.Links = linkableModels.JSONAPILinks()
|
||||||
|
}
|
||||||
|
|
||||||
|
if metableModels, ok := models.(Metable); ok {
|
||||||
|
payload.Meta = metableModels.JSONAPIMeta()
|
||||||
|
}
|
||||||
|
|
||||||
|
return payload, nil
|
||||||
case reflect.Ptr:
|
case reflect.Ptr:
|
||||||
// Check that the pointer was to a struct
|
// Check that the pointer was to a struct
|
||||||
if reflect.Indirect(vals).Kind() != reflect.Struct {
|
if reflect.Indirect(vals).Kind() != reflect.Struct {
|
||||||
|
|
Loading…
Reference in New Issue