api

package
v0.0.27 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2026 License: Apache-2.0 Imports: 11 Imported by: 9

Documentation

Index

Constants

View Source
const ErrorType = "Error"

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

Variables

View Source
var BuildTime = "unknown"

BuildTime is the time when the binary was built, set at compile time via ldflags

View Source
var Version = "unknown"

Version is the application version set at compile time via ldflags

Functions

func GetOpenAPISpec

func GetOpenAPISpec() ([]byte, error)

GetOpenAPISpec returns the embedded OpenAPI YAML file contents

func NewID

func NewID() string

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 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"`
	Version   string `json:"version"`
	BuildTime string `json:"build_time"`
}

Metadata api metadata.

type PagingMeta

type PagingMeta struct {
	Page  int
	Size  int64
	Total int64
}

PagingMeta List Paging metadata

Directories

Path Synopsis
grpc

Jump to

Keyboard shortcuts

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