api

package
v0.0.0-...-d3f7758 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const ErrorType = "Error"

ErrorType is the name of the type used to report errors.

Variables

This section is empty.

Functions

func NewID

func NewID() string

func SendAPI

func SendAPI(w http.ResponseWriter, r *http.Request)

SendAPI sends API documentation response.

func SendAPIV1

func SendAPIV1(w http.ResponseWriter, r *http.Request)

SendAPIV1 sends API version v1 documentation response.

func SendNotFound

func SendNotFound(w http.ResponseWriter, r *http.Request)

SendNotFound sends a 404 response with some details about the non existing resource.

func SendPanic

func SendPanic(w http.ResponseWriter, r *http.Request)

SendPanic sends a panic error response to the client, but it doesn't end the process.

func SendUnauthorized

func SendUnauthorized(w http.ResponseWriter, r *http.Request, message string)

Types

type CollectionMetadata

type CollectionMetadata struct {
	ID   string `json:"id"`
	HREF string `json:"href"`
	Kind string `json:"kind"`
}

CollectionMetadata represents a collection.

type Dinosaur

type Dinosaur struct {
	Meta
	Species string
}

func (*Dinosaur) BeforeCreate

func (d *Dinosaur) BeforeCreate(tx *gorm.DB) error

type DinosaurIndex

type DinosaurIndex map[string]*Dinosaur

type DinosaurList

type DinosaurList []*Dinosaur

func (DinosaurList) Index

func (l DinosaurList) Index() DinosaurIndex

type DinosaurPatchRequest

type DinosaurPatchRequest struct {
	Species *string `json:"species,omitempty"`
}

type Error

type Error struct {
	Type   string `json:"type,omitempty"`
	ID     string `json:"id,omitempty"`
	HREF   string `json:"href,omitempty"`
	Code   string `json:"code,omitempty"`
	Reason string `json:"reason,omitempty"`
}

Error represents an error reported by the API.

type Event

type Event struct {
	Meta
	Source         string     // MyTable
	SourceID       string     // primary key of MyTable
	EventType      EventType  // Add|Update|Delete
	ReconciledDate *time.Time `json:"gorm:null"`
}

func (*Event) BeforeCreate

func (d *Event) BeforeCreate(tx *gorm.DB) error

type EventIndex

type EventIndex map[string]*Event

type EventList

type EventList []*Event

func (EventList) Index

func (l EventList) Index() EventIndex

type EventType

type EventType string
const (
	CreateEventType EventType = "Create"
	UpdateEventType EventType = "Update"
	DeleteEventType EventType = "Delete"
)

type Meta

type Meta struct {
	ID        string
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt gorm.DeletedAt `gorm:"index"`
}

Meta is base model definition, embedded in all kinds

type Metadata

type Metadata struct {
	ID       string            `json:"id"`
	HREF     string            `json:"href"`
	Kind     string            `json:"kind"`
	Versions []VersionMetadata `json:"versions"`
}

Metadata api metadata.

type PagingMeta

type PagingMeta struct {
	Page  int
	Size  int64
	Total int64
}

List Paging metadata

type VersionMetadata

type VersionMetadata struct {
	ID          string               `json:"id"`
	HREF        string               `json:"href"`
	Kind        string               `json:"kind"`
	Collections []CollectionMetadata `json:"collections"`
}

VersionMetadata represents a version.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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