apiresponse

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func End

func End[T Respond](rp T, w http.ResponseWriter, r *http.Request)

func ErrorAndEnd

func ErrorAndEnd[T Respond](rp T, err error, w http.ResponseWriter, r *http.Request)

func Start

func Start[T Respond](rp T, w http.ResponseWriter, r *http.Request)

func Stop

func Stop[T Respond](rp T, w http.ResponseWriter, r *http.Request)

Types

type DataAge

type DataAge struct {
	Min string `json:"min"`
	Max string `json:"max"`
}

type RequestTimings

type RequestTimings struct {
	Start   time.Time `json:"start"`
	End     time.Time `json:"end"`
	Seconds float64   `json:"duration"`
}

func (*RequestTimings) Duration

func (rt *RequestTimings) Duration() time.Duration

type Respond

type Respond interface {
	StatusGet() int
	StatusSet(status int)
	ErrorAdd(err error)
	ErrorGet() []string
	Timer() *RequestTimings
}

type Response

type Response struct {
	RequestTimer *RequestTimings `json:"request_timings,omitempty"`
	DataAge      *DataAge        `json:"data_age"`
	StatusCode   int             `json:"status"`
	Errors       []string        `json:"errors"`
	StartDate    string          `json:"start_date"`
	EndDate      string          `json:"end_date"`
	DateRange    []string        `json:"date_range"`

	// hide all of these, only used on the front reader
	Organisation     string                                `json:"-"`
	PageTitle        string                                `json:"-"`
	NavigationTop    map[string]*navigation.NavigationItem `json:"-"`
	NavigationSide   []*navigation.NavigationItem          `json:"-"`
	NavigationActive *navigation.NavigationItem            `json:"-"`
	Rows             map[string]map[string]interface{}     `json:"-"`
	// contains filtered or unexported fields
}

func (*Response) ErrorAdd

func (rp *Response) ErrorAdd(err error)

func (*Response) ErrorGet

func (rp *Response) ErrorGet() []string

func (*Response) StatusGet

func (rp *Response) StatusGet() int

func (*Response) StatusSet

func (rp *Response) StatusSet(status int)

func (*Response) Timer

func (rp *Response) Timer() *RequestTimings

Jump to

Keyboard shortcuts

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