Versions in this module Expand all Collapse all v2 v2.3.1 Jan 17, 2023 Changes in this version type Request + Pagination string v2.3.0 Aug 31, 2021 Changes in this version type Request + Search string v2.2.0 Aug 30, 2021 v2.1.1 Aug 26, 2021 v2.1.0 Aug 20, 2021 Changes in this version + const NullLink + type Link string + func (l *Link) UnmarshalJSON(data []byte) error + func (l Link) MarshalJSON() ([]byte, error) type Request + PageAfter string + PageBefore string + func (r *Request) Path() string + func (r Request) Merge(reqs ...Request) Request v2.0.1 Nov 6, 2020 v2.0.0 Jan 23, 2020 Changes in this version + const MediaType + func WriteError(w http.ResponseWriter, err error) error + func WriteErrorList(w http.ResponseWriter, errors ...*Error) error + func WriteResource(w http.ResponseWriter, status int, resource *Resource, links *DocumentLinks, ...) error + func WriteResources(w http.ResponseWriter, status int, resources []*Resource, links *DocumentLinks, ...) error + func WriteResponse(w http.ResponseWriter, status int, doc *Document) error + type Client struct + func NewClient(config ClientConfig) *Client + func NewClientWithClient(config ClientConfig, client *http.Client) *Client + func (c *Client) Create(res *Resource) (*Document, error) + func (c *Client) Delete(typ, id string) error + func (c *Client) Do(req Request, doc *Document) (*Document, error) + func (c *Client) Find(typ, id string, reqs ...Request) (*Document, error) + func (c *Client) List(typ string, reqs ...Request) (*Document, error) + func (c *Client) Update(res *Resource) (*Document, error) + type ClientConfig struct + Authorizer func(*http.Request) + BaseURI string + ResponseLimit int64 + type Document struct + Data *HybridResource + Errors []*Error + Included []*Resource + Links *DocumentLinks + Meta Map + func ParseDocument(r io.Reader) (*Document, error) + type DocumentLinks struct + First string + Last string + Next string + Previous string + Related string + Self string + type Error struct + Code string + Detail string + ID string + Links *ErrorLinks + Meta Map + Source *ErrorSource + Status int + Title string + func BadRequest(detail string) *Error + func BadRequestParam(detail, param string) *Error + func BadRequestPointer(detail, pointer string) *Error + func ErrorFromStatus(status int, detail string) *Error + func InternalServerError(detail string) *Error + func NotFound(detail string) *Error + func (e *Error) Error() string + type ErrorLinks struct + About string + type ErrorSource struct + Parameter string + Pointer string + type HybridResource struct + Many []*Resource + One *Resource + func (r *HybridResource) MarshalJSON() ([]byte, error) + func (r *HybridResource) UnmarshalJSON(doc []byte) error + type Intent int + const AppendToRelationship + const CollectionAction + const CreateResource + const DeleteResource + const FindResource + const GetRelatedResources + const GetRelationship + const ListResources + const RemoveFromRelationship + const ResourceAction + const SetRelationship + const UpdateResource + func (i Intent) DocumentExpected() bool + func (i Intent) RequestMethod() string + type Map map[string]interface + func (m Map) Assign(target interface{}) error + func StructToMap(source interface{}, fields []string) (Map, error) + type Parser struct + CollectionActions map[string][]string + Prefix string + ResourceActions map[string][]string + func (p *Parser) ParseRequest(r *http.Request) (*Request, error) + type Request struct + CollectionAction string + Fields map[string][]string + Filters map[string][]string + Include []string + Intent Intent + PageLimit int64 + PageNumber int64 + PageOffset int64 + PageSize int64 + Prefix string + RelatedResource string + Relationship string + ResourceAction string + ResourceID string + ResourceType string + Sorting []string + func ParseRequest(r *http.Request, prefix string) (*Request, error) + func (r *Request) Base() string + func (r *Request) Query() url.Values + func (r *Request) Self() string + type Resource struct + Attributes Map + ID string + Meta Map + Relationships map[string]*Document + Type string + type Server struct + Config ServerConfig + Counter int + Data map[string]map[string]*Resource + Mutex sync.Mutex + Parser *Parser + func NewServer(config ServerConfig) *Server + func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) + type ServerConfig struct + Prefix string + Types []string Other modules containing this package github.com/256dpi/jsonapi