Documentation ¶
Index ¶
- Constants
- Variables
- func GetLocalIP() string
- func IncludesString(texts []string, text string) bool
- func NewGinEngine(logger *zap.Logger, options *DSockOptions) *gin.Engine
- func PingHandler(c *gin.Context)
- func RandomString(length int) string
- func RemoveEmpty(texts []string) []string
- func RemoveString(texts []string, text string) []string
- func SetupConfig() error
- func TokenMiddleware(token string) gin.HandlerFunc
- func UniqueString(texts []string) []string
- type ApiError
- type DSockOptions
- type JwtOptions
- type ResolveOptions
Constants ¶
View Source
const ( PathPing = "/ping" PathSend = "/send" PathConnect = "/connect" PathClaim = "/claim" PathInfo = "/info" PathDisconnect = "/disconnect" PathChannelSubscribe = "/channel/subscribe/:channel" PathChannelUnsubscribe = "/channel/unsubscribe/:channel" PathReceiveMessage = "/_/message" PathReceiveChannelMessage = "/_/message/channel" )
View Source
const ( ErrorUserIdRequired = "USER_ID_REQUIRED" ErrorInvalidExpiration = "INVALID_EXPIRATION" ErrorNegativeExpiration = "NEGATIVE_EXPIRATION" ErrorInvalidDuration = "INVALID_DURATION" ErrorNegativeDuration = "NEGATIVE_DURATION" ErrorGettingConnection = "ERROR_GETTING_CONNECTION" ErrorGettingUser = "ERROR_GETTING_USER" ErrorGettingChannel = "ERROR_GETTING_CHANNEL" ErrorTarget = "MISSING_TARGET" ErrorInvalidAuthorization = "INVALID_AUTHORIZATION" ErrorMissingAuthentication = "MISSING_AUTHENTICATION" ErrorInvalidJwt = "INVALID_JWT" ErrorClaimIdAlreadyUsed = "CLAIM_ID_ALREADY_USED" ErrorCheckingClaim = "ERROR_CHECKING_CLAIM" ErrorGettingClaim = "ERROR_GETTING_CLAIM" ErrorMissingClaim = "MISSING_CLAIM" ErrorExpiredClaim = "EXPIRED_CLAIM" ErrorReadingMessage = "ERROR_READING_MESSAGE" ErrorMarshallingMessage = "ERROR_MARSHALLING_MESSAGE" ErrorInvalidMessageType = "INVALID_MESSAGE_TYPE" ErrorBindingQueryParams = "ERROR_BINDING_QUERY_PARAMS" ErrorGettingWorker = "ERROR_GETTING_WORKER" ErrorReachingWorker = "ERROR_REACHING_WORKER" ErrorDeliveringMessage = "ERROR_DELIVERING_MESSAGING" ErrorInvalidContentType = "INVALID_CONTENT_TYPE" ErrorReadingBody = "ERROR_READING_BODY" )
View Source
const MessageMethodDirect = "direct"
View Source
const MessageMethodRedis = "redis"
View Source
const ProtobufContentType = "application/protobuf"
Variables ¶
View Source
var DSockVersion = "v0.4.1"
View Source
var ErrorMessages = map[string]string{ ErrorUserIdRequired: "User ID is required", ErrorInvalidExpiration: "Error parsing expiration (must be a integer)", ErrorNegativeExpiration: "Can not use 0 or negative expiration", ErrorInvalidDuration: "Could not parse duration (must be a integer)", ErrorNegativeDuration: "Can not use 0 or negative duration", ErrorGettingConnection: "Error getting connection", ErrorGettingUser: "Error getting user", ErrorGettingChannel: "Error getting channel", ErrorTarget: "Missing target", ErrorInvalidAuthorization: "Invalid authorization", ErrorMissingAuthentication: "Did not provide an authentication method", ErrorInvalidJwt: "Could not validate JWT", ErrorClaimIdAlreadyUsed: "Claim ID is already used", ErrorCheckingClaim: "Error checking if claim already exists", ErrorGettingClaim: "Error getting claim", ErrorMissingClaim: "Could not find claim", ErrorExpiredClaim: "Claim has expired", ErrorReadingMessage: "Error reading message", ErrorMarshallingMessage: "Error marshalling message", ErrorInvalidMessageType: "Invalid message type, must be text or binary", ErrorBindingQueryParams: "Error binding query parameters", ErrorGettingWorker: "Error getting worker", ErrorReachingWorker: "Error reaching worker", ErrorDeliveringMessage: "Error delivering message", ErrorInvalidContentType: "Invalid Content-Type", ErrorReadingBody: "Error reading body", }
Functions ¶
func GetLocalIP ¶ added in v0.4.0
func GetLocalIP() string
func IncludesString ¶ added in v0.3.0
func NewGinEngine ¶ added in v0.3.1
func NewGinEngine(logger *zap.Logger, options *DSockOptions) *gin.Engine
func PingHandler ¶ added in v0.3.3
func RandomString ¶
func RemoveEmpty ¶ added in v0.1.2
func RemoveString ¶
func SetupConfig ¶
func SetupConfig() error
func TokenMiddleware ¶
func TokenMiddleware(token string) gin.HandlerFunc
/ Validates that token matches from query parameter or from Authorization header
func UniqueString ¶
Types ¶
type ApiError ¶ added in v0.1.2
type ApiError struct { /// Wrapped error. Can be nil if application/validation error InternalError error /// Error code. Used to take error message from ErrorMessages ErrorCode string /// If set, overrides error message from ErrorCode CustomErrorMessage string /// HTTP status code StatusCode int /// Request ID RequestId string }
type DSockOptions ¶
type DSockOptions struct { RedisOptions *redis.Options Address string Port int QuitChannel chan struct{} Debug bool LogRequests bool /// Token for your API -> dSock and between dSock services Token string /// JWT parsing/verifying options Jwt JwtOptions /// Default channels to subscribe on join DefaultChannels []string /// The message method between the API to the worker MessagingMethod string /// The worker hostname DirectHostname string /// The worker port DirectPort int }
func GetOptions ¶
func GetOptions(worker bool) (*DSockOptions, error)
type JwtOptions ¶
type JwtOptions struct {
JwtSecret string
}
Source Files ¶
Click to show internal directories.
Click to hide internal directories.