Documentation ¶
Overview ¶
Package aphjsapi provides additional interfaces, wrapper and helper functions for original jsapi package("github.com/manyminds/api2go/jsapi")
Index ¶
- func GetAttributeFields(data interface{}) []string
- func GetFilterAttributes(data interface{}) []string
- func GetTypeName(data interface{}) string
- func MapFieldsToDbRow(data interface{}) map[string]string
- func MarshalToStructWrapper(data interface{}, ep jsapi.ServerInformation) (*jsapi.Document, error)
- func MarshalWithPagination(data interface{}, ep jsapi.ServerInformation, opt *pagination.Props) (*jsapi.Document, error)
- type AttributeToDbRowMapper
- type MarshalRelatedRelations
- type MarshalSelfRelations
- type Permission
- type RelationShipLink
- type RelationshipAttribute
- type Role
- type User
- func (u *User) GetID() string
- func (u *User) GetReferencedIDs() []jsonapi.ReferenceID
- func (u *User) GetReferencedStructs() []jsonapi.MarshalIdentifier
- func (u *User) GetReferences() []jsonapi.Reference
- func (u *User) GetRelatedLinksInfo() []RelationShipLink
- func (u *User) GetSelfLinksInfo() []RelationShipLink
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetAttributeFields ¶
func GetAttributeFields(data interface{}) []string
GetAttributeNames returns all JSAONAPI attribute names of data interface
func GetFilterAttributes ¶
func GetFilterAttributes(data interface{}) []string
GetFilterAttributes gets all the JSONAPI attributes that are allowed to match filter query params
func GetTypeName ¶
func GetTypeName(data interface{}) string
GetTypeName gets the type name(type field) from a jsapi implementing interface. It is recommended to implement jsapi.EntityNamer interface to reduce the use of reflection
func MapFieldsToDbRow ¶
MapFieldsToDbRow maps jsapi attributes to database row names
func MarshalToStructWrapper ¶
func MarshalToStructWrapper(data interface{}, ep jsapi.ServerInformation) (*jsapi.Document, error)
MarshalToStructWrapper adds relationship information and returns a jsapi.Document structure for further json encoding
func MarshalWithPagination ¶
func MarshalWithPagination(data interface{}, ep jsapi.ServerInformation, opt *pagination.Props) (*jsapi.Document, error)
MarshalWithPagination adds pagination information for collection resource
Types ¶
type AttributeToDbRowMapper ¶
AttributeToDbRowMapper is an interface to provide mapping between jsapi attribute and database row names. This is useful for implementing filter query parameter
type MarshalRelatedRelations ¶
type MarshalRelatedRelations interface {
GetRelatedLinksInfo() []RelationShipLink
}
MarshalRelatedRelations is an interface for creating related relationship links
type MarshalSelfRelations ¶
type MarshalSelfRelations interface {
GetSelfLinksInfo() []RelationShipLink
}
MarshalSelfRelations is an interface for creating self relationship links
type Permission ¶
type Permission struct { ID string `json:"-"` Permission string `json:"permission"` Description string `json:"description"` }
func (Permission) GetID ¶
func (p Permission) GetID() string
type RelationShipLink ¶
type RelationShipLink struct { Name string // To override the default links, it will be appended to // the base url. SuffixFragment string }
RelationshipLink is a container type for having information about relationship links
func GetAllRelationships ¶
func GetAllRelationships(data interface{}) []RelationShipLink
GetAllRelationships returns all relationships of data interface
type RelationshipAttribute ¶
RelationshipAttributes is an interface to provide attribute fields of relationship resources. This is mandatory for supporting sparse fieldset query parameter.
type Role ¶
type Role struct { ID string `json:"-"` Role string `json:"role"` Description string `json:"description"` Permissions []*Permission `json:"-"` Users []*User `json:"-"` }
func (*Role) GetRelatedLinksInfo ¶
func (r *Role) GetRelatedLinksInfo() []RelationShipLink
func (*Role) GetSelfLinksInfo ¶
func (r *Role) GetSelfLinksInfo() []RelationShipLink
type User ¶
type User struct { ID string `json:"-"` Name string `json:"name,omitempty" filter:"-"` Email string `json:"email,omitempty" filter:"-"` Roles []*Role `json:"-"` }
func (*User) GetReferencedIDs ¶
func (u *User) GetReferencedIDs() []jsonapi.ReferenceID
GetReferencedIDs satisfies jsonapi.MarshalLinkedRelations interface
func (*User) GetReferencedStructs ¶
func (u *User) GetReferencedStructs() []jsonapi.MarshalIdentifier
GetReferencedStructs satisfies jsonapi.MarshalIncludedRelations interface
func (*User) GetReferences ¶
GetReferences satisfies jsonapi.MarshalReferences interface
func (*User) GetRelatedLinksInfo ¶
func (u *User) GetRelatedLinksInfo() []RelationShipLink
GetSelfLinksInfo satisfies MarshalRelatedRelations interface
func (*User) GetSelfLinksInfo ¶
func (u *User) GetSelfLinksInfo() []RelationShipLink
GetSelfLinksInfo satisfies MarshalSelfRelations interface