Documentation ¶
Index ¶
- Constants
- Variables
- type APIController
- func (c *APIController) AbortBadRequest(msg string)
- func (c *APIController) AbortBadRequestFormat(paramName string)
- func (c *APIController) AbortForbidden(msg string)
- func (c *APIController) AbortInternalServerError(msg string)
- func (c *APIController) AbortUnauthorized(msg string)
- func (c *APIController) BuildQueryParam() *common.QueryParam
- func (c *APIController) CheckPermission(perType string, perAction string)
- func (c *APIController) ErrorResult(code int, msg string) []byte
- func (c *APIController) GetBoolParamFromQuery(param string) bool
- func (c *APIController) GetBoolParamFromQueryWithDefault(param string, defaultValue bool) bool
- func (c *APIController) GetDeleteFromQuery() bool
- func (c *APIController) GetIDFromURL() int64
- func (c *APIController) GetIntParamFromQuery(param string) int64
- func (c *APIController) GetIntParamFromURL(param string) int64
- func (c *APIController) GetIsOnlineFromQuery() bool
- func (c *APIController) GetLogicalFromQuery() bool
- func (c *APIController) HandleError(err error)
- func (c *APIController) Prepare()
- func (c *APIController) Success(data interface{})
- type APIKeyController
- type ErrorResult
- type ErrorSubCode
- type LoggedInController
- type Result
Constants ¶
View Source
const (
ErrorSubCodeInsufficientResource = 403001
)
Variables ¶
View Source
var (
PublishRequestMessageMethodFilter = []string{
"POST",
"PUT",
"DELETE",
"PATCH",
}
)
Functions ¶
This section is empty.
Types ¶
type APIController ¶
type APIController struct { LoggedInController NamespaceId int64 AppId int64 }
func (*APIController) AbortBadRequest ¶
func (c *APIController) AbortBadRequest(msg string)
func (*APIController) AbortBadRequestFormat ¶
func (c *APIController) AbortBadRequestFormat(paramName string)
format BadRequest with param name.
func (*APIController) AbortForbidden ¶
func (c *APIController) AbortForbidden(msg string)
Abort stops controller handler and show the error data, e.g. Prepare
func (*APIController) AbortInternalServerError ¶
func (c *APIController) AbortInternalServerError(msg string)
func (*APIController) AbortUnauthorized ¶
func (c *APIController) AbortUnauthorized(msg string)
func (*APIController) BuildQueryParam ¶
func (c *APIController) BuildQueryParam() *common.QueryParam
TODO: 需要重构成独立的Controller,参考Django的generic views设计
func (*APIController) CheckPermission ¶
func (c *APIController) CheckPermission(perType string, perAction string)
* 检查资源权限
func (*APIController) ErrorResult ¶
func (c *APIController) ErrorResult(code int, msg string) []byte
func (*APIController) GetBoolParamFromQuery ¶
func (c *APIController) GetBoolParamFromQuery(param string) bool
func (*APIController) GetBoolParamFromQueryWithDefault ¶
func (c *APIController) GetBoolParamFromQueryWithDefault(param string, defaultValue bool) bool
func (*APIController) GetDeleteFromQuery ¶
func (c *APIController) GetDeleteFromQuery() bool
func (*APIController) GetIDFromURL ¶
func (c *APIController) GetIDFromURL() int64
func (*APIController) GetIntParamFromQuery ¶
func (c *APIController) GetIntParamFromQuery(param string) int64
func (*APIController) GetIntParamFromURL ¶
func (c *APIController) GetIntParamFromURL(param string) int64
func (*APIController) GetIsOnlineFromQuery ¶
func (c *APIController) GetIsOnlineFromQuery() bool
func (*APIController) GetLogicalFromQuery ¶
func (c *APIController) GetLogicalFromQuery() bool
func (*APIController) HandleError ¶
func (c *APIController) HandleError(err error)
Handle return http code and body normally, need return
func (*APIController) Prepare ¶
func (c *APIController) Prepare()
func (*APIController) Success ¶
func (c *APIController) Success(data interface{})
type APIKeyController ¶
type APIKeyController struct { beego.Controller APIKey *models.APIKey Action string Sucess response.Success Failure response.Failure }
func (*APIKeyController) AddError ¶
func (c *APIKeyController) AddError(err string)
func (*APIKeyController) AddErrorAndResponse ¶
func (c *APIKeyController) AddErrorAndResponse(err string, code int)
func (*APIKeyController) HandleByCode ¶
func (c *APIKeyController) HandleByCode(code int)
func (*APIKeyController) HandleResponse ¶
func (c *APIKeyController) HandleResponse(data interface{})
用于负责 get 数据的接口,当 error 列表不为空的时候,返回 error 列表 当 参数为 nil 的时候,返回 "200"
func (*APIKeyController) Prepare ¶
func (c *APIKeyController) Prepare()
*
- 通过 apikey 参数判断调用权限
- apikey 类型:全局apikey(管理员可用)、命名空间级别的 apikey 和项目级别的 apikey(app 内部可用) *
type ErrorResult ¶
type ErrorResult struct { // http code Code int `json:"code"` // The custom code SubCode int `json:"subCode"` Msg string `json:"msg"` }
func (*ErrorResult) Error ¶
func (e *ErrorResult) Error() string
Error implements the Error interface.
type ErrorSubCode ¶
type ErrorSubCode int
type LoggedInController ¶
type LoggedInController struct { beego.Controller User *models.User }
func (*LoggedInController) Prepare ¶
func (c *LoggedInController) Prepare()
Click to show internal directories.
Click to hide internal directories.