Documentation ¶
Index ¶
- type BaseAPI
- func (b *BaseAPI) DecodeJSONReq(v interface{})
- func (b *BaseAPI) DecodeJSONReqAndValidate(v interface{})
- func (b *BaseAPI) GetIDFromURL() int64
- func (b *BaseAPI) GetInt64FromPath(key string) (int64, error)
- func (b *BaseAPI) GetPaginationParams() (page, pageSize int64)
- func (b *BaseAPI) GetStringFromPath(key string) string
- func (b *BaseAPI) HandleBadRequest(text string)
- func (b *BaseAPI) HandleConflict(text ...string)
- func (b *BaseAPI) HandleForbidden(username string)
- func (b *BaseAPI) HandleInternalServerError(text string)
- func (b *BaseAPI) HandleNotFound(text string)
- func (b *BaseAPI) HandleStatusPreconditionFailed(text string)
- func (b *BaseAPI) HandleUnauthorized()
- func (b *BaseAPI) ParseAndHandleError(text string, err error)
- func (b *BaseAPI) Redirect(statusCode int, resouceID string)
- func (b *BaseAPI) Render() error
- func (b *BaseAPI) RenderError(code int, text string)
- func (b *BaseAPI) SetPaginationHeader(total, page, pageSize int64)
- func (b *BaseAPI) Validate(v interface{})
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 ¶
GetIDFromURL checks the ID in request URL
func (*BaseAPI) GetInt64FromPath ¶
GetInt64FromPath gets the param from path and returns it as int64
func (*BaseAPI) GetPaginationParams ¶
GetPaginationParams ...
func (*BaseAPI) GetStringFromPath ¶
GetStringFromPath gets the param from path and returns it as string
func (*BaseAPI) HandleBadRequest ¶
HandleBadRequest ...
func (*BaseAPI) HandleConflict ¶
HandleConflict ...
func (*BaseAPI) HandleForbidden ¶
HandleForbidden ...
func (*BaseAPI) HandleInternalServerError ¶
HandleInternalServerError ...
func (*BaseAPI) HandleStatusPreconditionFailed ¶
HandleStatusPreconditionFailed ...
func (*BaseAPI) ParseAndHandleError ¶
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) RenderError ¶
RenderError provides shortcut to render http error
func (*BaseAPI) SetPaginationHeader ¶
SetPaginationHeader set"Link" and "X-Total-Count" header for pagination request