-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlinks.go
More file actions
49 lines (43 loc) · 1.06 KB
/
links.go
File metadata and controls
49 lines (43 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package jsonapi
import (
"github.com/neuronlabs/neuron/codec"
)
// TopLinks is used to represent a `links` object.
// http://jsonapi.org/format/#document-links
type TopLinks struct {
Self string `json:"self,omitempty"`
Related string `json:"related,omitempty"`
First string `json:"first,omitempty"`
Prev string `json:"prev,omitempty"`
Next string `json:"next,omitempty"`
Last string `json:"last,omitempty"`
}
// SetPaginationLinks sets the pagination links from the marshal options
func (t *TopLinks) SetPaginationLinks(o *codec.PaginationLinks) {
// if pagination links are set
if o == nil {
return
}
if o.Self != "" {
t.Self = o.Self
}
if o.First != "" {
t.First = o.First
}
if o.Last != "" {
t.Last = o.Last
}
if o.Next != "" {
t.Next = o.Next
}
if o.Prev != "" {
t.Prev = o.Prev
}
}
// Links is the structure used to represent a related 'links' object.
type Links map[string]interface{}
// Link is used to represent a member of the `links` object.
type Link struct {
Href string `json:"href"`
Meta Meta `json:"meta,omitempty"`
}