Documentation ¶
Overview ¶
Package rest rest context
Package rest xxx
Index ¶
- Variables
- func APIResponse(c *Context, data interface{})
- func AbortWithBadRequestError(c *Context, err error)
- func AbortWithJSONError(c *Context, err error)
- func AbortWithUnauthorizedError(c *Context, err error)
- func AbortWithWithForbiddenError(c *Context, err error)
- func RestHandlerFunc(handler HandlerFunc) gin.HandlerFunc
- func STDRestHandlerFunc(handler HandlerFunc) gin.HandlerFunc
- func StreamHandler(handler StreamHandlerFunc) gin.HandlerFunc
- type APIGWApp
- type APIGWToken
- type APIGWUser
- type Context
- type EnvToken
- type HandlerFunc
- type Result
- type StreamHandlerFunc
- type UserClaimsInfo
Constants ¶
This section is empty.
Variables ¶
View Source
var ( errors.New("用户未登入") )ErrorUnauthorized =
Functions ¶
func AbortWithBadRequestError ¶
AbortWithBadRequestError 请求失败
func AbortWithJSONError ¶
AbortWithJSONError 目前的UI规范, 返回200状态码, 通过里面的code判断请求成功与否
func AbortWithUnauthorizedError ¶
AbortWithUnauthorizedError 未登入
func AbortWithWithForbiddenError ¶
AbortWithWithForbiddenError 没有权限
func RestHandlerFunc ¶
func RestHandlerFunc(handler HandlerFunc) gin.HandlerFunc
RestHandlerFunc rest handler
func STDRestHandlerFunc ¶
func STDRestHandlerFunc(handler HandlerFunc) gin.HandlerFunc
STDRestHandlerFunc 标准handler, 错误返回非200状态码
func StreamHandler ¶
func StreamHandler(handler StreamHandlerFunc) gin.HandlerFunc
StreamHandler 流式 Handler
Types ¶
type APIGWToken ¶
type APIGWToken struct { App *APIGWApp `json:"app"` User *APIGWUser `json:"user"` *jwt.StandardClaims }
APIGWToken 返回信息
type Context ¶
type Context struct { *gin.Context RequestId string `json:"request_id"` StartTime time.Time `json:"start_time"` Operator string `json:"operator"` Username string `json:"username"` ProjectId string `json:"project_id"` ProjectCode string `json:"project_code"` ClusterId string `json:"cluster_id"` BindEnv *EnvToken `json:"bind_env"` BindBCS *UserClaimsInfo `json:"bind_bcs"` BindAPIGW *APIGWToken `json:"bind_apigw"` BindCluster *bcs.Cluster `json:"bind_cluster"` BindProject *bcs.Project `json:"bind_project"` }
Context xxx
func (*Context) WriteAttachment ¶
WriteAttachment 提供附件下载能力
type Result ¶
type Result struct { Code int `json:"code"` Message string `json:"message"` RequestId string `json:"request_id"` Data interface{} `json:"data"` }
Result 返回的标准结构
type UserClaimsInfo ¶
type UserClaimsInfo struct { SubType string `json:"sub_type"` UserName string `json:"username"` BKAppCode string `json:"bk_app_code"` ClientID string `json:"client_id"` ClientSecret string `json:"client_secret"` // https://tools.ietf.org/html/rfc7519#section-4.1 // aud: 接收jwt一方; exp: jwt过期时间; jti: jwt唯一身份认证; IssuedAt: 签发时间; Issuer: jwt签发者 *jwt.StandardClaims }
UserClaimsInfo custom jwt claims
Directories ¶
Path | Synopsis |
---|---|
Package middleware Authorization
|
Package middleware Authorization |
Package tracing request id
|
Package tracing request id |
Click to show internal directories.
Click to hide internal directories.