common

package
v0.1.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 16, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FatalError

func FatalError(message string, err error)

func GenerateUUID

func GenerateUUID() string

func GetEnv

func GetEnv() string

func GetEnvVariable

func GetEnvVariable(variable string) string

func GetLogLevelFromString

func GetLogLevelFromString(loglevel string) zapcore.Level

func InitLogging

func InitLogging(options LoggerOptions)

func IsJSON

func IsJSON(s string) bool

func LoadHtmlTemplates

func LoadHtmlTemplates(server *gin.Engine, templates map[string]string) error

func StrToInt

func StrToInt(value string) int

func StrToInt64

func StrToInt64(value string) int64

func WinningDefault

func WinningDefault(value string, values ...string) string

Function will pick first argument if it was not empty, or it will loop over the rest of the arguments And pick the first not empty one

Types

type Domain

type Domain struct {
	Public    string
	Websocket string
}

func BuildDomain

func BuildDomain(domain string, env string) *Domain

type IdentityMessage

type IdentityMessage struct {
	PeerId      string `json:"peerId"`
	Broadcaster bool   `json:"broadcaster"`
	Subscriber  bool   `json:"subscriber"`
}

type LogMessage

type LogMessage struct {
	Line string `json:"line"`
}

type LoggerOptions

type LoggerOptions struct {
	Env         string
	LogLevel    zapcore.Level
	LogFileName string
}

type Message

type Message struct {
	Id      string      `json:"id"`
	Payload interface{} `json:"payload"`
	Event   string      `json:"event"`
}

func NewMessageFromString

func NewMessageFromString(message []byte) (Message, error)

func (Message) Marshal

func (m Message) Marshal() ([]byte, error)

func (Message) MarshalLogObject

func (message Message) MarshalLogObject(encoder zapcore.ObjectEncoder) error

func (Message) MarshalPayload

func (m Message) MarshalPayload() ([]byte, error)

func (Message) ToIdentityMessage

func (m Message) ToIdentityMessage() (IdentityMessage, error)

func (Message) ToLogMessage

func (m Message) ToLogMessage() (LogMessage, error)

func (Message) ToSubscriberConnectedMessage

func (m Message) ToSubscriberConnectedMessage() (SubscriberConnectedMessage, error)

type SubscriberConnectedMessage

type SubscriberConnectedMessage struct {
	Connected bool `json:"connected"`
}

func (SubscriberConnectedMessage) Marshal

func (m SubscriberConnectedMessage) Marshal() ([]byte, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL