utils

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2021 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoCookie      = errors.New("failed to find token cookie")
	ErrInvalidCookie = errors.New("invalid cookie")
)

Functions

func NewCDN added in v0.7.0

func NewCDN(config CDNConfig) *s3.S3

NewCDN Initialise connection to CDN

func NewDB added in v0.7.0

func NewDB(config DatabaseConfig) (*sqlx.DB, error)

NewDB Initialises the connection to the database

func NewMQ added in v0.7.0

func NewMQ(conf MQConfig) (*amqp.Connection, error)

NewMQ initialising the AMQP broker

func Transact

func Transact(db *sqlx.DB, txFunc func(*sqlx.Tx) error) (err error)

Transact wraps transactions

Types

type CDNConfig added in v0.7.0

type CDNConfig struct {
	Endpoint        string
	Region          string
	AccessKeyID     string
	SecretAccessKey string
}

CDNConfig represents a configuration to connect to a CDN / S3 instance

type DatabaseConfig added in v0.7.0

type DatabaseConfig struct {
	Host     string
	Port     string
	SSLMode  string
	Name     string
	Username string
	Password string
}

DatabaseConfig represents a configuration to connect to an SQL database

type JWTClaims

type JWTClaims struct {
	UserID      int          `json:"id"`
	Permissions []Permission `json:"perms"`
	jwt.StandardClaims
}

JWTClaims represents an identifiable JWT

func GetToken added in v0.7.0

func GetToken(cookie *http.Cookie) (*JWTClaims, error)

func GetTokenEcho added in v0.7.0

func GetTokenEcho(c echo.Context) (*JWTClaims, error)

GetToken will return the JWT claims from a valid JWT token

func GetTokenHTTP added in v0.7.0

func GetTokenHTTP(r *http.Request) (*JWTClaims, error)

GetToken will return the JWT claims from a valid JWT token

type MQConfig added in v0.7.0

type MQConfig struct {
	Host     string
	Port     string
	Username string
	Password string
}

MQConfig configuration required to create a MQ connection

type Mail added in v0.7.0

type Mail struct {
	Subject string
	To      string
	Cc      []string
	Bcc     []string
	From    string
	// contains filtered or unexported fields
}

Mail represents an email to be sent

type MailConfig added in v0.7.0

type MailConfig struct {
	Host     string
	Port     int
	Username string
	Password string
}

MailConfig represents a configuration to connect to an SMTP server

type Mailer added in v0.7.0

type Mailer struct {
	*mail.SMTPClient
	Enabled bool
}

Mailer encapsulates the dependency

func NewMailer added in v0.7.0

func NewMailer(config MailConfig) (*Mailer, error)

NewMailer creates a new SMTP client

func (*Mailer) SendMail added in v0.7.0

func (m *Mailer) SendMail(item Mail) error

SendMail sends a template email

type Permission added in v0.7.0

type Permission struct {
	PermissionID int    `json:"id"`
	Name         string `json:"name"`
}

Permission represents the permissions that a user has

Jump to

Keyboard shortcuts

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