Documentation ¶
Index ¶
- Constants
- func EncodeError(w http.ResponseWriter, err error)
- type BadRequestError
- type Collection
- type CollectionLinks
- type Error
- type InternalServerError
- type Link
- type LinkBuilder
- func (b *LinkBuilder) AddQuery(key string, value string) *LinkBuilder
- func (b *LinkBuilder) AllowedMethod(allowedMethod string) *LinkBuilder
- func (b *LinkBuilder) Build(ctx app.Context) Link
- func (b *LinkBuilder) ExternalURL(fullExternalURL string) *LinkBuilder
- func (b *LinkBuilder) Meta(meta LinkMeta) *LinkBuilder
- func (b *LinkBuilder) Path(path string) *LinkBuilder
- func (b *LinkBuilder) Title(title string) *LinkBuilder
- func (b *LinkBuilder) UseParams(params app.Params) *LinkBuilder
- type LinkMeta
- type NotFoundError
- type Relationship
- type RelationshipBuilder
- func (b *RelationshipBuilder) AllowOnUninitialized() *RelationshipBuilder
- func (b *RelationshipBuilder) Build(ctx app.Context) *Relationship
- func (b *RelationshipBuilder) CheckState(checkStateFn func() bool) *RelationshipBuilder
- func (b *RelationshipBuilder) Data(data []ResourceIdentifier) *RelationshipBuilder
- func (b *RelationshipBuilder) IsAuthenticated() *RelationshipBuilder
- func (b *RelationshipBuilder) OnlyUnauthenticated() *RelationshipBuilder
- func (b *RelationshipBuilder) Related(link Link) *RelationshipBuilder
- func (b *RelationshipBuilder) Roles(roles []string) *RelationshipBuilder
- type Resource
- type ResourceBuilder
- func (b *ResourceBuilder[T, R]) Attributes(attributes T) *ResourceBuilder[T, R]
- func (b *ResourceBuilder[T, R]) Build() Resource[T, R]
- func (b *ResourceBuilder[T, R]) ID(id string) *ResourceBuilder[T, R]
- func (b *ResourceBuilder[T, R]) Relationships(relationships R) *ResourceBuilder[T, R]
- func (b *ResourceBuilder[T, R]) SelfLink(link Link) *ResourceBuilder[T, R]
- func (b *ResourceBuilder[T, R]) Type(resourceType string) *ResourceBuilder[T, R]
- type ResourceIdentifier
- type ResourceLinks
- type Response
Constants ¶
View Source
const DefaultLimit = 15
Variables ¶
This section is empty.
Functions ¶
func EncodeError ¶
func EncodeError(w http.ResponseWriter, err error)
Types ¶
type BadRequestError ¶
type BadRequestError struct {
// contains filtered or unexported fields
}
func NewBadRequestError ¶
func NewBadRequestError(msg string) BadRequestError
func (BadRequestError) Error ¶
func (e BadRequestError) Error() string
type Collection ¶
type Collection struct { Data any `json:"data"` Links CollectionLinks `json:"links"` }
func (Collection) Validate ¶
func (c Collection) Validate() error
type CollectionLinks ¶
type InternalServerError ¶
type InternalServerError struct {
// contains filtered or unexported fields
}
func NewInternalServerError ¶
func NewInternalServerError(msg string) InternalServerError
func (InternalServerError) Error ¶
func (e InternalServerError) Error() string
type LinkBuilder ¶
type LinkBuilder struct {
// contains filtered or unexported fields
}
func NewLinkBuilder ¶
func NewLinkBuilder() *LinkBuilder
func (*LinkBuilder) AddQuery ¶
func (b *LinkBuilder) AddQuery(key string, value string) *LinkBuilder
func (*LinkBuilder) AllowedMethod ¶
func (b *LinkBuilder) AllowedMethod(allowedMethod string) *LinkBuilder
func (*LinkBuilder) ExternalURL ¶
func (b *LinkBuilder) ExternalURL(fullExternalURL string) *LinkBuilder
Use this if you need the link to point to a resource that does not exist on this server. Otherwise, the server's host will be used when building the links
func (*LinkBuilder) Meta ¶
func (b *LinkBuilder) Meta(meta LinkMeta) *LinkBuilder
func (*LinkBuilder) Path ¶
func (b *LinkBuilder) Path(path string) *LinkBuilder
func (*LinkBuilder) Title ¶
func (b *LinkBuilder) Title(title string) *LinkBuilder
func (*LinkBuilder) UseParams ¶
func (b *LinkBuilder) UseParams(params app.Params) *LinkBuilder
type NotFoundError ¶
type NotFoundError struct {
// contains filtered or unexported fields
}
func NewNotFoundError ¶
func NewNotFoundError(msg string) NotFoundError
func (NotFoundError) Error ¶
func (e NotFoundError) Error() string
type Relationship ¶
type Relationship struct { Links ResourceLinks `json:"links"` Data []ResourceIdentifier `json:"data,omitempty"` }
https://jsonapi.org/format/#document-resource-object-relationships
type RelationshipBuilder ¶
type RelationshipBuilder struct {
// contains filtered or unexported fields
}
func NewRelationshipBuilder ¶
func NewRelationshipBuilder() *RelationshipBuilder
func (*RelationshipBuilder) AllowOnUninitialized ¶
func (b *RelationshipBuilder) AllowOnUninitialized() *RelationshipBuilder
func (*RelationshipBuilder) Build ¶
func (b *RelationshipBuilder) Build(ctx app.Context) *Relationship
func (*RelationshipBuilder) CheckState ¶
func (b *RelationshipBuilder) CheckState(checkStateFn func() bool) *RelationshipBuilder
func (*RelationshipBuilder) Data ¶
func (b *RelationshipBuilder) Data(data []ResourceIdentifier) *RelationshipBuilder
func (*RelationshipBuilder) IsAuthenticated ¶
func (b *RelationshipBuilder) IsAuthenticated() *RelationshipBuilder
func (*RelationshipBuilder) OnlyUnauthenticated ¶
func (b *RelationshipBuilder) OnlyUnauthenticated() *RelationshipBuilder
func (*RelationshipBuilder) Related ¶
func (b *RelationshipBuilder) Related(link Link) *RelationshipBuilder
func (*RelationshipBuilder) Roles ¶
func (b *RelationshipBuilder) Roles(roles []string) *RelationshipBuilder
type Resource ¶
type Resource[T any, R any] struct { ResourceIdentifier Attributes T `json:"attributes"` Links ResourceLinks `json:"links"` Relationships R `json:"relationships"` }
https://jsonapi.org/format/#document-resource-object-relationships
type ResourceBuilder ¶
func NewResourceBuilder ¶
func NewResourceBuilder[T any, R any]() *ResourceBuilder[T, R]
func (*ResourceBuilder[T, R]) Attributes ¶
func (b *ResourceBuilder[T, R]) Attributes(attributes T) *ResourceBuilder[T, R]
func (*ResourceBuilder[T, R]) Build ¶
func (b *ResourceBuilder[T, R]) Build() Resource[T, R]
func (*ResourceBuilder[T, R]) ID ¶
func (b *ResourceBuilder[T, R]) ID(id string) *ResourceBuilder[T, R]
func (*ResourceBuilder[T, R]) Relationships ¶
func (b *ResourceBuilder[T, R]) Relationships(relationships R) *ResourceBuilder[T, R]
func (*ResourceBuilder[T, R]) SelfLink ¶
func (b *ResourceBuilder[T, R]) SelfLink(link Link) *ResourceBuilder[T, R]
func (*ResourceBuilder[T, R]) Type ¶
func (b *ResourceBuilder[T, R]) Type(resourceType string) *ResourceBuilder[T, R]
type ResourceIdentifier ¶
type ResourceLinks ¶
type Response ¶
type Response struct {
// contains filtered or unexported fields
}
func (Response) Collection ¶
func (r Response) Collection() Collection
Source Files ¶
Click to show internal directories.
Click to hide internal directories.