common

package
v0.0.0-...-45a98ea Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2023 License: MIT Imports: 31 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AWSClients

type AWSClients struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

type App

type App struct {
	Clients
	AWSClients
	GCPClients

	sync.RWMutex
	// contains filtered or unexported fields
}

func NewApp

func NewApp() *App

func (*App) AddRoute

func (app *App) AddRoute(method, path string, handler gin.HandlerFunc)

func (*App) CompactSerial

func (app *App) CompactSerial(x interface{}) (string, error)

func (*App) Debug

func (app *App) Debug(state bool)

func (*App) Decrypt

func (app *App) Decrypt(key, ciphertext []byte) ([]byte, error)

func (*App) Encrypt

func (app *App) Encrypt(key, payload []byte) ([]byte, error)

func (*App) ExpandSerial

func (app *App) ExpandSerial(serial []byte, dst interface{}) error

func (*App) GetJSON

func (app *App) GetJSON(url string, dst interface{}) error

func (*App) GinHandleCORS

func (app *App) GinHandleCORS(c *gin.Context)

func (*App) HandleCORS

func (app *App) HandleCORS(w http.ResponseWriter, r *http.Request) bool

func (*App) IsDebug

func (app *App) IsDebug() bool

func (*App) MarshalCBOR

func (app *App) MarshalCBOR(x interface{}) ([]byte, error)

func (*App) MarshalJSON

func (app *App) MarshalJSON(x interface{}) ([]byte, error)

func (*App) NewAuthToken

func (app *App) NewAuthToken(subject string, customClaims map[string]interface{}) (string, error)

func (*App) ParseContentForArray

func (app *App) ParseContentForArray(content string, dst interface{}) error

func (*App) ParseContentForObject

func (app *App) ParseContentForObject(content string, dst interface{}) error

func (*App) ParseJSON

func (app *App) ParseJSON(r *http.Request, dst interface{}) error

func (*App) PostJSON

func (app *App) PostJSON(url string, src, dst interface{}, expectingStatus int, headers ...map[string]string) error

func (*App) SHA1

func (app *App) SHA1(b []byte) []byte

func (*App) SHA256

func (app *App) SHA256(b ...[]byte) []byte

func (*App) SeedDigest

func (app *App) SeedDigest(input string) string

func (*App) Serve

func (app *App) Serve() error

func (*App) ShowRoutes

func (app *App) ShowRoutes() interface{}

func (*App) TimeNow

func (app *App) TimeNow() time.Time

func (*App) Token256

func (api *App) Token256() string

func (*App) UnmarshalCBOR

func (app *App) UnmarshalCBOR(b []byte, dst interface{}) error

func (*App) UnmarshalJSON

func (app *App) UnmarshalJSON(b []byte, dst interface{}) error

func (*App) UseAlgolia

func (app *App) UseAlgolia(appID, secretPath string)

UseAlgolia initialises the algolia client

func (*App) UseCBOR

func (app *App) UseCBOR()

UseCBOR is an efficient encoding package, check it out

func (*App) UseGCP

func (app *App) UseGCP(projectID string)

UseGCP grants the conditions for the GCP services clients

func (*App) UseJWT

func (app *App) UseJWT(signingKey string)

UseJWT caches a secret signing key in memory

func (*App) ValidateToken

func (app *App) ValidateToken(tokenString string) (bool, string, error)

type Clients

type Clients struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func (*Clients) Algolia

func (self *Clients) Algolia() *search.Client

func (*Clients) Gin

func (self *Clients) Gin() *gin.Engine

UseGin enables a Gin instance

func (*Clients) HTTP

func (self *Clients) HTTP() *http.Client

type EmailClient

type EmailClient struct {
	Account  string
	Password string
	Host     string
	Port     string
}

func NewEmailClient

func NewEmailClient(account, password, host, port string) *EmailClient

func NewGmailClient

func NewGmailClient(account, password string) *EmailClient

func (*EmailClient) Address

func (self *EmailClient) Address() string

func (*EmailClient) SendMessage

func (self *EmailClient) SendMessage(message []byte, recipients ...string) error

type GCPClients

type GCPClients struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func (*GCPClients) AWSFirebase

func (self *GCPClients) AWSFirebase() *firebase.App

Firebase lazy loads the client when needed

func (*GCPClients) AWSFirestore

func (self *GCPClients) AWSFirestore() *firestore.Client

Firestore exposes and initalises the firestore db

func (*GCPClients) Firebase

func (self *GCPClients) Firebase() *firebase.App

Firebase lazy loads the client when needed

func (*GCPClients) Firestore

func (self *GCPClients) Firestore() *firestore.Client

Firestore exposes and initalises the firestore db

func (*GCPClients) GCS

func (self *GCPClients) GCS() *storage.Client

func (*GCPClients) GetObjectAndUnmarshal

func (self *GCPClients) GetObjectAndUnmarshal(ctx context.Context, bucket *storage.BucketHandle, objectName string, dst interface{}) error

func (*GCPClients) GetObjectGCS

func (self *GCPClients) GetObjectGCS(ctx context.Context, bucket *storage.BucketHandle, objectName string) ([]byte, error)

func (*GCPClients) ListObjectsGCS

func (self *GCPClients) ListObjectsGCS(ctx context.Context, bucketName, prefix string) (names []string, err error)

ListObjectGCS returns the contents of the directory with the given prefix

func (*GCPClients) PubSub

func (self *GCPClients) PubSub() *pubsub.Client

func (*GCPClients) S3

func (self *GCPClients) S3() *storage.Client

func (*GCPClients) SNS

func (self *GCPClients) SNS() *pubsub.Client

type MyCustomClaims

type MyCustomClaims struct {
	jwt.RegisteredClaims
	Custom map[string]interface{} `json:"custom"`
}

type Route

type Route struct {
	Method  string
	Path    string
	Handler gin.HandlerFunc `json:"-"`
}

Jump to

Keyboard shortcuts

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