Documentation ¶
Index ¶
- Constants
- Variables
- func AssembleResponse(c *gin.Context, data interface{}, err error)
- func ConstructError(ec Code, a ...interface{}) error
- func GetContext(c *gin.Context) context.Context
- func HandleError(c *gin.Context, code Code, msg ...interface{})
- func NoRoute() gin.HandlerFunc
- func SetContext() gin.HandlerFunc
- func SetErrorAndAbort(c *gin.Context, code Code, msg ...interface{})
- func SetRequestID() gin.HandlerFunc
- func URL(url string) string
- func ValidateHeaders() gin.HandlerFunc
- type Code
- type ContextKeyType
Constants ¶
const ( // ContextKey is used as key to set/get context. ContextKey = "context" // ContentTypeJSON : json ContentTypeJSON = "application/json" // ContentTypeOctetStream: octet stream ContentTypeOctetStream = "application/octet-stream" // HeaderTraceID is header name for trace id. HeaderTraceID = "x-fc-trace-id" HeaderContentType = "content-Type" HeaderContentLength = "content-Length" // HeaderClientIP is the real IP of the remote client HeaderClientIP = "clientIP" )
Header Keys
const ( RootPath = "/api" EnvironmentPath = "/envs" ApplicationPath = "/apps" WorkloadDefinitionPath = "/workloads" ComponentDefinitionPath = "/components" ScopeDefinitionPath = "/scopes" TraitDefinitionPath = "/traits" CapabilityPath = "/capabilities" CapabilityCenterPath = "/capability-centers" VersionPath = "/version" Definition = "/definitions" )
RESTful API paths
const DefaultAPIServerPort = ":38081"
DefaultAPIServerPort refers to the default port number of APIServer
Variables ¶
var DefaultDashboardPort = ":38081"
DefaultDashboardPort refers to the default port number of dashboard
Functions ¶
func AssembleResponse ¶
AssembleResponse assembles response data to return
func ConstructError ¶
ConstructError returns a new OpError.
func GetContext ¶
GetContext get the context from the gin context
func HandleError ¶
HandleError will handle error
func NoRoute ¶
func NoRoute() gin.HandlerFunc
NoRoute is a handler which is invoked when there is no route matches.
func SetContext ¶
func SetContext() gin.HandlerFunc
SetContext :Set context metadata for request Before get request
func SetErrorAndAbort ¶
SetErrorAndAbort is used to abort the rest of the handlers, mostly called in middleware
func ValidateHeaders ¶
func ValidateHeaders() gin.HandlerFunc
ValidateHeaders validates the common headers.
It reports one problem at a time.
Types ¶
type Code ¶
type Code int
Code defines the error code type.
type ContextKeyType ¶
type ContextKeyType string
ContextKeyType defining the context key type for the middleware
const ( // ServiceLogFields shared key service log fields ServiceLogFields ContextKeyType = "ServiceLogFields" // HeaderRequestID is used as key to set/get request id. HeaderRequestID ContextKeyType = "x-fc-request-id" )