Documentation ¶
Index ¶
- Constants
- func Cors(h http.Handler, isAllowedOriginsFunc func(string) ([]string, bool)) http.Handler
- func ErrorLogWriter(ctx *gin.Context)
- func ExtractIP(c *gin.Context) string
- func GinLogErrorBody(c *gin.Context)
- func TokenAuth(main gin.HandlerFunc, originalToken string) gin.HandlerFunc
- func TokenFuncAuth(main gin.HandlerFunc, isAllowedOriginsFunc func(string) ([]string, bool), ...) gin.HandlerFunc
- func TokenTwoFuncAuth(main gin.HandlerFunc, isAllowedOriginsFunc func(string) ([]string, bool), ...) gin.HandlerFunc
- type AdminToken
- type ErrorResponse
- type GinErrorBodyWriter
- type StatusResponse
Constants ¶
const ( AdminTokenErr = "Admin token does not match" AdminTokenKey = "X-Admin-Token" )
const ( TokenName = "token" APIKeyName = "api_key" TokenHeaderName = "x-auth-token" ErrTokenNotFound = "The token is not found: %s" JitsuAnonymIDCookie = "__eventn_id" CookiePolicyParameter = "cookie_policy" IPPolicyParameter = "ip_policy" KeepValue = "keep" StrictValue = "strict" ComplyValue = "comply" )
const ( StatusOK = "ok" StatusPending = "pending" )
Variables ¶
This section is empty.
Functions ¶
func Cors ¶
Cors handles OPTIONS requests and check if request /event or dynamic event endpoint or static endpoint (/t /s /p) if token ok => check origins - if matched write origin to acao header otherwise don't write it if not returns 401
func ErrorLogWriter ¶
func GinLogErrorBody ¶
func TokenAuth ¶
func TokenAuth(main gin.HandlerFunc, originalToken string) gin.HandlerFunc
TokenAuth check that provided token equals
func TokenFuncAuth ¶
func TokenFuncAuth(main gin.HandlerFunc, isAllowedOriginsFunc func(string) ([]string, bool), errMsg string) gin.HandlerFunc
TokenFuncAuth check that provided token: 1. is valid 2. exists in specific (js or api) token config
func TokenTwoFuncAuth ¶
func TokenTwoFuncAuth(main gin.HandlerFunc, isAllowedOriginsFunc func(string) ([]string, bool), anotherTypeAllowedOriginsFunc func(string) ([]string, bool), errMsg string) gin.HandlerFunc
TokenTwoFuncAuth check that provided token: 1. is valid 2. exists in specific (js or api) token config if not return err msg depend on existing in another token config
Types ¶
type AdminToken ¶
type AdminToken struct {
Token string
}
func (*AdminToken) AdminAuth ¶
func (a *AdminToken) AdminAuth(main gin.HandlerFunc) gin.HandlerFunc
type ErrorResponse ¶
type ErrorResponse struct { Message string `json:"message"` Payload interface{} `json:"payload,omitempty"` //Deprecated Error string `json:"error"` }
ErrorResponse is a dto for sending error response
func ErrResponse ¶
func ErrResponse(msg string, err error) *ErrorResponse
ErrResponse is a constructor for ErrorResponse
type GinErrorBodyWriter ¶
type GinErrorBodyWriter struct { gin.ResponseWriter // contains filtered or unexported fields }
type StatusResponse ¶
type StatusResponse struct { Status string `json:"status"` Message string `json:"message,omitempty"` }
StatusResponse is a dto for sending operation status
func OKResponse ¶
func OKResponse() StatusResponse
OKResponse returns StatusResponse with Status = "ok"
func PendingResponse ¶
func PendingResponse() StatusResponse
PendingResponse returns StatusResponse with Status = "pending"