utils

package
v0.0.0-...-1d10f4c Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PrefixInfo – light blue
	PrefixInfo = "\t" + CInfo + "INFO:" + CEnd + "\t"
	// PrefixNotice – purple
	PrefixNotice = "\t" + CNotice + "NOTICE:" + CEnd + "\t"
	// PrefixWarning – yellow
	PrefixWarning = "\t" + CWarning + "WARNING:" + CEnd + "\t"
	// PrefixError – red
	PrefixError = "\t" + CError + "ERROR:" + CEnd + "\t"
	// PrefixDebug – cyan
	PrefixDebug = "\t" + CDebug + "DEBUG:" + CEnd + "\t"
	// PrefixEnd – of the color
	PrefixEnd = "\t" + "\033[0m"

	// CInfo light blue
	CInfo = "\033[1;34m"
	// CNotice purple
	CNotice = "\033[1;35m"
	// CWarning yellow
	CWarning = "\033[1;33m"
	// CError red
	CError = "\033[1;31m"
	// CDebug cyan
	CDebug = "\033[0;36m"
	// CEnd of the color
	CEnd = "\033[0m"
)

Variables

This section is empty.

Functions

func GetENV

func GetENV() string

GetENV ...

func GetPWD

func GetPWD() string

GetPWD ...

func GetPort

func GetPort() string

GetPort ...

func InitLogger

func InitLogger()

InitLogger ...

func LogDebug

func LogDebug(items ...interface{})

LogDebug ...

func LogError

func LogError(items ...interface{})

LogError ...

func LogInfo

func LogInfo(items ...interface{})

LogInfo ...

func LogNotice

func LogNotice(items ...interface{})

LogNotice ...

func LogWarning

func LogWarning(items ...interface{})

LogWarning ...

func RenderInternalError

func RenderInternalError(ctx *http.RequestCtx, msg string)

RenderInternalError ...

func RenderNotFoundError

func RenderNotFoundError(ctx *http.RequestCtx, msg string)

RenderNotFoundError ...

func RenderUnauthorized

func RenderUnauthorized(ctx *http.RequestCtx, msg string)

RenderUnauthorized ...

func RenderValidationErrors

func RenderValidationErrors(ctx *http.RequestCtx, verrors map[string][]string)

RenderValidationErrors ...

func SetStatus

func SetStatus(ctx *http.RequestCtx, code int)

SetStatus ...

func WriteError

func WriteError(ctx *http.RequestCtx, code int, obj interface{})

WriteError ...

func WriteJSON

func WriteJSON(ctx *http.RequestCtx, obj interface{})

WriteJSON ...

Types

type Client

type Client struct {
	ID         string
	Connection *websocket.Conn
	UserID     int
}

Client ...

func NewClient

func NewClient(conn *websocket.Conn) Client

NewClient ...

func (*Client) Send

func (client *Client) Send(message []byte) error

Send ...

func (*Client) SendJSON

func (client *Client) SendJSON(obj interface{}) error

SendJSON ...

func (*Client) SendJSONError

func (client *Client) SendJSONError(action, str string)

SendJSONError ...

func (*Client) SendJSONStatus

func (client *Client) SendJSONStatus(action, str string)

SendJSONStatus ...

type JwtClaim

type JwtClaim struct {
	UserID int
	jwt.StandardClaims
}

JwtClaim adds email as a claim to the token

type JwtWrapper

type JwtWrapper struct {
	SecretKey       string
	Issuer          string
	ExpirationHours int64
}

JwtWrapper wraps the signing key and the issuer

func (*JwtWrapper) GenerateToken

func (j *JwtWrapper) GenerateToken(userID int) (signedToken string, err error)

GenerateToken generates a jwt token

func (*JwtWrapper) ValidateToken

func (j *JwtWrapper) ValidateToken(signedToken string) (claims *JwtClaim, err error)

ValidateToken validates the jwt token

type Message

type Message struct {
	Action   string          `json:"action"`
	Topic    string          `json:"topic"`
	Message  json.RawMessage `json:"message"`
	Filters  json.RawMessage `json:"filters"`
	Event    json.RawMessage `json:"event"`
	Slot     json.RawMessage `json:"slot"`
	TimeZone *string         `json:"timezone"`
}

Message ...

func NewMessage

func NewMessage() Message

NewMessage ...

type PgxLogger

type PgxLogger struct{}

PgxLogger ...

func (*PgxLogger) Log

func (l *PgxLogger) Log(ctx context.Context, level pgx.LogLevel, msg string, data map[string]interface{})

Log ...

type PubSub

type PubSub struct {
	Clients       []Client
	Subscriptions []Subscription
}

PubSub ...

func (*PubSub) AddClient

func (ps *PubSub) AddClient(client Client) *PubSub

AddClient ...

func (*PubSub) GetSubscriptions

func (ps *PubSub) GetSubscriptions(topic string, client *Client) []Subscription

GetSubscriptions ...

func (*PubSub) Publish

func (ps *PubSub) Publish(topic string, message []byte, excludeClient *Client)

Publish ...

func (*PubSub) RemoveClient

func (ps *PubSub) RemoveClient(client Client) *PubSub

RemoveClient ...

func (*PubSub) Subscribe

func (ps *PubSub) Subscribe(client *Client, topic string) *PubSub

Subscribe ...

func (*PubSub) Unsubscribe

func (ps *PubSub) Unsubscribe(client *Client, topic string) *PubSub

Unsubscribe ...

type Subscription

type Subscription struct {
	Topic  string
	Client *Client
}

Subscription ...

Jump to

Keyboard shortcuts

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