forked from Mirrors/jsonapi
return function return value when is only err
This commit is contained in:
parent
9246c912f5
commit
6bf44faa3c
|
@ -12,10 +12,7 @@ import (
|
|||
// http://jsonapi.org/format/#document-top-level
|
||||
// and here: http://jsonapi.org/format/#error-objects.
|
||||
func MarshalErrors(w io.Writer, errorObjects []*ErrorObject) error {
|
||||
if err := json.NewEncoder(w).Encode(&ErrorsPayload{Errors: errorObjects}); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
return json.NewEncoder(w).Encode(&ErrorsPayload{Errors: errorObjects})
|
||||
}
|
||||
|
||||
// ErrorsPayload is a serializer struct for representing a valid JSON API errors payload.
|
||||
|
|
16
response.go
16
response.go
|
@ -68,10 +68,7 @@ func MarshalPayload(w io.Writer, models interface{}) error {
|
|||
return err
|
||||
}
|
||||
|
||||
if err := json.NewEncoder(w).Encode(payload); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
return json.NewEncoder(w).Encode(payload)
|
||||
}
|
||||
|
||||
// Marshal does the same as MarshalPayload except it just returns the payload
|
||||
|
@ -128,10 +125,7 @@ func MarshalPayloadWithoutIncluded(w io.Writer, model interface{}) error {
|
|||
}
|
||||
payload.clearIncluded()
|
||||
|
||||
if err := json.NewEncoder(w).Encode(payload); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
return json.NewEncoder(w).Encode(payload)
|
||||
}
|
||||
|
||||
// marshalOne does the same as MarshalOnePayload except it just returns the
|
||||
|
@ -195,11 +189,7 @@ func MarshalOnePayloadEmbedded(w io.Writer, model interface{}) error {
|
|||
|
||||
payload := &OnePayload{Data: rootNode}
|
||||
|
||||
if err := json.NewEncoder(w).Encode(payload); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return json.NewEncoder(w).Encode(payload)
|
||||
}
|
||||
|
||||
func visitModelNode(model interface{}, included *map[string]*Node,
|
||||
|
|
Loading…
Reference in New Issue