base

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2018 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

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()

type Result

type Result struct {
	Data interface{} `json:"data"`
}

Jump to

Keyboard shortcuts

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