jsonapi

package
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 18, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Stringify

func Stringify(v any) string

Types

type Error

type Error struct {
	ID     string
	Status int
	Code   string
	Title  string
	Detail string
}

func (Error) JSONAPISerialize

func (j Error) JSONAPISerialize() (string, error)

type ErrorCompatible added in v0.0.2

type ErrorCompatible interface {
	ToJSONAPIError() Error
}

type Errors

type Errors []Error

func (Errors) JSONAPISerialize

func (j Errors) JSONAPISerialize() (string, error)

type Nil

type Nil struct{}

func (Nil) JSONAPISerialize

func (n Nil) JSONAPISerialize() (string, error)

type Relationship

type Relationship struct {
	Data ResourceIdentifier
}

func (Relationship) JSONAPISerialize

func (j Relationship) JSONAPISerialize() (string, error)

type RelationshipHasMany

type RelationshipHasMany struct {
	Data []ResourceIdentifier
}

func (RelationshipHasMany) JSONAPISerialize

func (j RelationshipHasMany) JSONAPISerialize() (string, error)

type Relationships

type Relationships map[string]Serializer

func (Relationships) JSONAPISerialize

func (j Relationships) JSONAPISerialize() (string, error)

type Resource

type Resource struct {
	ID            string
	Type          string
	Attributes    Serializer
	Relationships Relationships
}

func (Resource) JSONAPISerialize

func (j Resource) JSONAPISerialize() (string, error)

type ResourceIdentifier

type ResourceIdentifier struct {
	ID   string
	Type string
}

func (ResourceIdentifier) JSONAPISerialize

func (j ResourceIdentifier) JSONAPISerialize() (string, error)

type Resourcer

type Resourcer interface {
	ToJSONAPIResource() (data Resource, included Resources)
}

type Resources

type Resources struct {
	Data []Resource
	// contains filtered or unexported fields
}

func (*Resources) Append

func (j *Resources) Append(r ...Resource)

func (Resources) JSONAPISerialize

func (j Resources) JSONAPISerialize() (string, error)

type Root

type Root[T Serializer] struct {
	Data     T
	Errors   Errors
	Meta     Serializer
	Included Resources
}

func New

func New(data Resource, includes Resources, meta Serializer) *Root[Resource]

func NewErrors

func NewErrors(errors Errors) *Root[Nil]

func NewMany

func NewMany(data Resources, includes Resources, meta Serializer) *Root[Resources]

func NewManyFrom

func NewManyFrom[T Resourcer](list []T, meta Serializer) *Root[Resources]

func (Root[T]) Serialize

func (j Root[T]) Serialize() (string, error)

type Serializer

type Serializer interface {
	JSONAPISerialize() (string, error)
}

type Serializers

type Serializers []Serializer

func (Serializers) JSONAPISerialize

func (s Serializers) JSONAPISerialize() (string, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL