base

package
v0.0.0-...-1084665 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2020 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 ResponseController

type ResponseController struct {
	beego.Controller
	InputURL string
	Code     int
	Res      struct {
		Href    string                 `json:"href,omitempty"`
		Message string                 `json:"message,omitempty"`
		Size    int                    `json:"size,omitempty"`
		Offset  int                    `json:"offset,omitempty"`
		Limit   int                    `json:"limit,omitempty"`
		Links   []ResponseLink         `json:"links,omitempty"`
		Items   []interface{}          `json:"items,omitempty"`
		Errors  map[string]interface{} `json:"errors,omitempty"`
	}
}

ResponseController is used for all ResponseControllers and contains the most basic elements

func (*ResponseController) AppendItems

func (c *ResponseController) AppendItems(items ...interface{})

AppendItems appends items to the response

func (c *ResponseController) AppendLinks(links ...ResponseLink)

AppendLinks appends links to the response

func (*ResponseController) AppendOffsetLimitSize

func (c *ResponseController) AppendOffsetLimitSize(offset, limit, size int)

AppendOffsetLimitSize appends offset and limit to output next/previous/all-links

func (*ResponseController) GetOffsetLimit

func (c *ResponseController) GetOffsetLimit() (offset, limit int)

GetOffsetLimit checks input offset/limit, and sets default values if not found

func (*ResponseController) Prepare

func (c *ResponseController) Prepare()

Prepare is used to prepare the ResponseController

func (*ResponseController) SendResponse

func (c *ResponseController) SendResponse(code int, msg ...interface{})

SendResponse sets JSON output formatted for web

type ResponseLink struct {
	Rel    string `json:"rel,omitempty"`
	Method string `json:"method"`
	Href   string `json:"href" `
}

ResponseLink is used to reference other rescources in the API

Jump to

Keyboard shortcuts

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