File tree Expand file tree Collapse file tree 1 file changed +19
-1
lines changed
Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -84,7 +84,25 @@ func Marshal(models interface{}) (Payloader, error) {
8484 if err != nil {
8585 return nil , err
8686 }
87- return marshalMany (m )
87+
88+ payload , err := marshalMany (m )
89+ if err != nil {
90+ return nil , err
91+ }
92+
93+ if linkableModels , isLinkable := models .(Linkable ); isLinkable {
94+ jl := linkableModels .JSONAPILinks ()
95+ if er := jl .validate (); er != nil {
96+ return nil , er
97+ }
98+ payload .Links = linkableModels .JSONAPILinks ()
99+ }
100+
101+ if metableModels , ok := models .(Metable ); ok {
102+ payload .Meta = metableModels .JSONAPIMeta ()
103+ }
104+
105+ return payload , nil
88106 case reflect .Ptr :
89107 // Check that the pointer was to a struct
90108 if reflect .Indirect (vals ).Kind () != reflect .Struct {
You can’t perform that action at this time.
0 commit comments