api

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2018 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseAPI

type BaseAPI struct {
	beego.Controller
}

BaseAPI wraps common methods for controllers to host API

func (*BaseAPI) DecodeJSONReq

func (b *BaseAPI) DecodeJSONReq(v interface{})

DecodeJSONReq decodes a json request

func (*BaseAPI) DecodeJSONReqAndValidate

func (b *BaseAPI) DecodeJSONReqAndValidate(v interface{})

DecodeJSONReqAndValidate does both decoding and validation

func (*BaseAPI) GetIDFromURL

func (b *BaseAPI) GetIDFromURL() int64

GetIDFromURL checks the ID in request URL

func (*BaseAPI) GetInt64FromPath

func (b *BaseAPI) GetInt64FromPath(key string) (int64, error)

GetInt64FromPath gets the param from path and returns it as int64

func (*BaseAPI) GetPaginationParams

func (b *BaseAPI) GetPaginationParams() (page, pageSize int64)

GetPaginationParams ...

func (*BaseAPI) GetStringFromPath

func (b *BaseAPI) GetStringFromPath(key string) string

GetStringFromPath gets the param from path and returns it as string

func (*BaseAPI) HandleBadRequest

func (b *BaseAPI) HandleBadRequest(text string)

HandleBadRequest ...

func (*BaseAPI) HandleConflict

func (b *BaseAPI) HandleConflict(text ...string)

HandleConflict ...

func (*BaseAPI) HandleForbidden

func (b *BaseAPI) HandleForbidden(username string)

HandleForbidden ...

func (*BaseAPI) HandleInternalServerError

func (b *BaseAPI) HandleInternalServerError(text string)

HandleInternalServerError ...

func (*BaseAPI) HandleNotFound

func (b *BaseAPI) HandleNotFound(text string)

HandleNotFound ...

func (*BaseAPI) HandleUnauthorized

func (b *BaseAPI) HandleUnauthorized()

HandleUnauthorized ...

func (*BaseAPI) ParseAndHandleError

func (b *BaseAPI) ParseAndHandleError(text string, err error)

ParseAndHandleError : if the err is an instance of utils/error.Error, return the status code and the detail message contained in err, otherwise return 500

func (*BaseAPI) Redirect

func (b *BaseAPI) Redirect(statusCode int, resouceID string)

Redirect does redirection to resource URI with http header status code.

func (*BaseAPI) Render

func (b *BaseAPI) Render() error

Render returns nil as it won't render template

func (*BaseAPI) RenderError

func (b *BaseAPI) RenderError(code int, text string)

RenderError provides shortcut to render http error

func (*BaseAPI) SetPaginationHeader

func (b *BaseAPI) SetPaginationHeader(total, page, pageSize int64)

SetPaginationHeader set"Link" and "X-Total-Count" header for pagination request

func (*BaseAPI) Validate

func (b *BaseAPI) Validate(v interface{})

Validate validates v if it implements interface validation.ValidFormer

Jump to

Keyboard shortcuts

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