response

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2020 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Assembler

type Assembler struct {
	// contains filtered or unexported fields
}

Assembler is to marshal records

func New

func New(collection *meta.Collection, resourceLocation string) *Assembler

New creates a new Assembler that marshals records

func (*Assembler) HTMLError

func (m *Assembler) HTMLError(error *errors.Error) (int, []byte)

func (*Assembler) HTMLResponse

func (m *Assembler) HTMLResponse(c echo.Context, response *MatrixResponse) error

func (*Assembler) JSONError

func (m *Assembler) JSONError(error *errors.Error) (int, interface{})

func (*Assembler) JSONResponse

func (m *Assembler) JSONResponse(c echo.Context, response *MatrixResponse) error

func (*Assembler) Marshal

func (m *Assembler) Marshal(records []*matrix.Matrix, query *matrix.Query) *MatrixResponse

Marshal marshals records with their dependencies and gives MatrixResponse that contains rich metadata for current state of controllers

type MatrixResponse

type MatrixResponse struct {
	Request *RequestMetadata `json:"request,omitempty"`
	Query   *matrix.Query    `json:"query,omitempty"`

	// CacheStatus represents statuses of underlying controllers and caches of current response
	CacheStatus map[string]*status.Status `json:"cache,omitempty"`

	Items  []*item.Item     `json:"items,omitempty"`
	Matrix []*matrix.Matrix `json:"matrix,omitempty"`
	Stages []*stage.Stage   `json:"stages,omitempty"`
	Zones  []*zone.Zone     `json:"zones,omitempty"`
}

MatrixResponse consists additional data from the matrix result itself

func NewResponse

func NewResponse() *MatrixResponse

NewResponse creates a new MatrixResponse

type RequestMetadata

type RequestMetadata struct {
	// Mirror is the preferred mirror to select from; oftenly chose with reference of `CF-IPCountry` header
	Mirror string `json:"mirror,omitempty"`
}

RequestMetadata describes metadata related to the subsequent request

Jump to

Keyboard shortcuts

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