hal

package
v0.2.3-alpha-5 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ApiProblem

type ApiProblem struct {
	DescribedBy string `json:"describedBy"`          // a URL to a document describing the error condition (required)
	Title       string `json:"title"`                // a brief title for the error condition (required)
	HttpStatus  int    `json:"httpStatus,omitempty"` // the HTTP status code for the current request (optional)
	Details     string `json:"details,omitempty"`    // error details specific to this request (optional)
	SupportID   string `json:"supportId,omitempty"`  // a URL to the specific problem occurrence (e.g., to a log message) (optional)
}

ApiProblem describes an API error according to the API-Problem proposed standard. https://phlyrestfully.readthedocs.io/en/latest/problems.html https://datatracker.ietf.org/doc/html/draft-nottingham-http-problem-02

func NewApiProblem

func NewApiProblem(statusCode int, err error) ApiProblem

type Collection

type Collection[T any] struct {
	*query.Pagination
	*ResourceEmbeds[T]
	*ResourceLinks
}

Collection represents a paginated list of API content. https://phlyrestfully.readthedocs.io/en/latest/halprimer.html#collections

func NewCollection

func NewCollection[T any](resources []T, q query.Builder, linkUrl *url.URL) Collection[[]T]
type Link struct {
	Href string `json:"href"`
}
func NewLink(href string) Link
type Links map[string]Link

type Message

type Message struct {
	Message string `json:"message"`
	Resource
}

func NewMessage

func NewMessage(msg, path string, embedded ...any) Message

type Resource

type Resource struct {
	*ResourceEmbeds[any]
	*ResourceLinks
}

Resource represents an individual piece of content exposed by the API. https://phlyrestfully.readthedocs.io/en/latest/halprimer.html#resources

func NewResource

func NewResource(selfHref string, embedded ...any) Resource

type ResourceEmbeds

type ResourceEmbeds[T any] struct {
	Embeds T `json:"_embedded,omitempty" gorm:"embedded"`
}

func NewEmbeds

func NewEmbeds[T any](embeds T) *ResourceEmbeds[T]
type ResourceLinks struct {
	Links `json:"_links,omitempty" gorm:"-"`
}
func NewCollectionLinks(q query.Builder, linkUrl *url.URL) *ResourceLinks
func NewLinks() *ResourceLinks
func NewResourceLinks(selfHref string) *ResourceLinks
func (l *ResourceLinks) AddLink(key string, link Link) *ResourceLinks

Jump to

Keyboard shortcuts

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