Documentation
¶
Index ¶
- Constants
- Variables
- func AutoForwardToMaintainerWrapper(f func(*gin.Context)) func(*gin.Context)
- func BodyDecrypt(skipRoutes ...string) func(*gin.Context)
- func ForwardRequest(c *gin.Context, agentInfo meta.AgentInfoInterface, param interface{})
- func HeaderDecrypt(skipRoutes ...string) func(*gin.Context)
- func IsApiRoute(c *gin.Context) bool
- func IsLocalRoute(c *gin.Context) bool
- func NewContextWithTraceId(c *gin.Context) context.Context
- func PaddingBody() func(*gin.Context)
- func PostHandlers(excludeRoutes ...string) func(*gin.Context)
- func PreHandlers(maskBodyRoutes ...string) func(*gin.Context)
- func Recovery(c *gin.Context, err interface{})
- func SendNoContentResponse(c *gin.Context, err error)
- func SendResponse(c *gin.Context, data interface{}, err error)
- func SetApiFlag(c *gin.Context)
- func SetContentType(c *gin.Context)
- func SetLocalRouteFlag(c *gin.Context)
- func UnixSocketMiddleware() func(*gin.Context)
- func Verify(routeType ...secure.RouteType) func(*gin.Context)
- func VerifyAgentRoutes(c *gin.Context, curTs int64, header *secure.HttpHeader, ...)
- func VerifyFile() func(*gin.Context)
- func VerifyForSetAgentPassword(c *gin.Context, curTs int64, header *secure.HttpHeader, ...)
- func VerifyObRouters(c *gin.Context, curTs int64, header *secure.HttpHeader, ...)
- func VerifyTaskRoutes(c *gin.Context, curTs int64, header *secure.HttpHeader, ...)
- type UNIX_CONNECT_TYPE
Constants ¶
const ( IsAutoForwardedFlag = "IsAutoForward" // IsAutoForwardedFlag marks whether the current request is auto forwarded FollowerAgentOfForward = "FollowerAgentOfForward" // FollowerAgentOfForward is where the request is auto forwarded from )
const ( OcsAgentResponseKey = "ocsAgentResponse" TraceIdKey = "traceId" )
const (
ACCEPT_LANGUAGE = constant.ACCEPT_LANGUAGE
)
Variables ¶
var OCS_CUSTOMIZE_HEADER = []string{ ACCEPT_LANGUAGE, }
OCS_CUSTOMIZE_HEADER is the customize header that will be delivered when forward request.
Functions ¶
func BodyDecrypt ¶
func ForwardRequest ¶
func ForwardRequest(c *gin.Context, agentInfo meta.AgentInfoInterface, param interface{})
ForwardRequest is used by handler to forward the request to other agent.
func HeaderDecrypt ¶
func IsApiRoute ¶
func IsLocalRoute ¶
func NewContextWithTraceId ¶
NewContextWithTraceId extracts the traceId value from the Gin context and embeds it into a new standard context, which can be used in subsequent operations that require tracing.
func PaddingBody ¶
func PostHandlers ¶
PostHandlers returns a Gin middleware function that logs the response and duration of API requests.
func PreHandlers ¶
PreHandlers returns a Gin middleware function to extract and log trace IDs from incoming HTTP requests, and to log request details.
func Recovery ¶
Recovery is a utility function meant to be used with the Gin middleware for panic recovery.
func SendNoContentResponse ¶
func SendResponse ¶
SendResponse constructs a standardized response object and attaches it to the Gin context. It is typically used to ensure that all HTTP responses have a consistent format.
func SetApiFlag ¶
func SetContentType ¶
SetContentType is a Gin middleware that forces the Content-Type of all responses to "application/json". This is particularly useful to handle cases where gin might set the Content-Type to "text/plain" due to certain types of errors, such as JSON binding errors.
func SetLocalRouteFlag ¶
func UnixSocketMiddleware ¶
UnixSocketMiddleware creates a Gin middleware to enforce authorization for requests coming from Unix domain sockets.
func VerifyAgentRoutes ¶
func VerifyAgentRoutes(c *gin.Context, curTs int64, header *secure.HttpHeader, passwordType secure.VerifyType)
func VerifyFile ¶
func VerifyForSetAgentPassword ¶
func VerifyForSetAgentPassword(c *gin.Context, curTs int64, header *secure.HttpHeader, passwordType secure.VerifyType)
func VerifyObRouters ¶
func VerifyObRouters(c *gin.Context, curTs int64, header *secure.HttpHeader, passwordType secure.VerifyType)
func VerifyTaskRoutes ¶
func VerifyTaskRoutes(c *gin.Context, curTs int64, header *secure.HttpHeader, passwordType secure.VerifyType)
Types ¶
type UNIX_CONNECT_TYPE ¶
type UNIX_CONNECT_TYPE string
const UNIX_CONNECT UNIX_CONNECT_TYPE = "unix_conn"