Documentation
¶
Index ¶
- func DockerUtils() (du *dockerUtils)
- func HashUtils() *hashUtils
- func JsonUtils() *jsonUtils
- func PrintBanner(banner string)
- func RecoverAll(cb func(v any))
- func RecoverAny(errors []error, cb func(v any))
- func RecoverOne(e error, cb func(v any))
- func SetSecret(secret, vector []byte) error
- func StringUtils() *stringUtils
- func TimeUtils(ts Timestamp) *timeUtils
- type DockerContainer
- func (c *DockerContainer) AutoRemove(value bool) *DockerContainer
- func (c *DockerContainer) EntryPoint(args ...string) *DockerContainer
- func (c *DockerContainer) Exists() bool
- func (c *DockerContainer) IsRunning() bool
- func (c *DockerContainer) Label(label, value string) *DockerContainer
- func (c *DockerContainer) Labels(label map[string]string) *DockerContainer
- func (c *DockerContainer) Name(value string) *DockerContainer
- func (c *DockerContainer) Port(external, internal string) *DockerContainer
- func (c *DockerContainer) Ports(ports map[string]string) *DockerContainer
- func (c *DockerContainer) Run() error
- func (c *DockerContainer) Stop() error
- func (c *DockerContainer) Var(key, value string) *DockerContainer
- func (c *DockerContainer) Vars(vars map[string]string) *DockerContainer
- type HttpUtilsStruct
- func (u *HttpUtilsStruct) New(method, url string) *HttpUtilsStruct
- func (u *HttpUtilsStruct) Send() (*http.Response, error)
- func (u *HttpUtilsStruct) WithBody(body string) *HttpUtilsStruct
- func (u *HttpUtilsStruct) WithHeader(key, value string) *HttpUtilsStruct
- func (u *HttpUtilsStruct) WithHeaders(headers map[string]string) *HttpUtilsStruct
- func (u *HttpUtilsStruct) WithTimeout(timeout int) *HttpUtilsStruct
- type TokenUtilsStruct
- func (t *TokenUtilsStruct) CreateApiKey(appName string) (string, error)
- func (t *TokenUtilsStruct) CreateToken(claims *jwt.RegisteredClaims) (string, error)
- func (t *TokenUtilsStruct) ParseApiKey(apiKey string) (string, error)
- func (t *TokenUtilsStruct) ParseToken(tokenString string) (*jwt.RegisteredClaims, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DockerUtils ¶ added in v1.1.5
func DockerUtils() (du *dockerUtils)
DockerUtils is a simple utility to execute docker commands using shell This utility does not us the docker client library (due to compatability issues) but instead utilizes the shell command executor (from os/exec package). The pre-requisite
func HashUtils ¶
func HashUtils() *hashUtils
HashUtils is a factory method that acts as a static member
func PrintBanner ¶ added in v1.2.89
func PrintBanner(banner string)
PrintBanner displays the application's banner and lists all configuration variables along with their values in alphabetical order. This function is designed to provide a clear overview of the application's current configuration state at startup or when needed, facilitating easier debugging and configuration verification. It ensures that the configuration variables are presented in a sorted manner for quick reference and readability.
func RecoverAll ¶
func RecoverAll(cb func(v any))
RecoverAll performs recover for all panics.
Sample usage:
defer RecoverAll(func(err any) { fmt.Printf("got error: %s", err) })
func RecoverAny ¶
RecoverAny calls the callback function: cb with recovered value in case when recovered value exists in slice errors.
Sample usage:
defer recover.Any([]error{ErrorUsernameBlank, ErrorUsernameAlreadyTaken}, func(err any) { fmt.Printf("got error: %s", err) })
func RecoverOne ¶
RecoverOne calls the callback function: cb with recovered value in case when recovered value equals to e otherwise panic won't be recovered and will be propagated.
Sample usage:
defer recover.One(ErrorUsernameBlank, func(err any) { fmt.Printf("got error: %s", err) })
Types ¶
type DockerContainer ¶ added in v1.1.5
type DockerContainer struct {
// contains filtered or unexported fields
}
DockerContainer is used to construct docker container spec for the docker engine.
func (*DockerContainer) AutoRemove ¶ added in v1.1.5
func (c *DockerContainer) AutoRemove(value bool) *DockerContainer
AutoRemove determines whether to automatically remove the container when it has stopped
func (*DockerContainer) EntryPoint ¶ added in v1.1.5
func (c *DockerContainer) EntryPoint(args ...string) *DockerContainer
EntryPoint sets the entrypoint arguments of the container.
func (*DockerContainer) Exists ¶ added in v1.1.5
func (c *DockerContainer) Exists() bool
Exists return true if the container exists
func (*DockerContainer) IsRunning ¶ added in v1.1.7
func (c *DockerContainer) IsRunning() bool
IsRunning return true if the container exists and running
func (*DockerContainer) Label ¶ added in v1.1.5
func (c *DockerContainer) Label(label, value string) *DockerContainer
Label adds custom label
func (*DockerContainer) Labels ¶ added in v1.1.5
func (c *DockerContainer) Labels(label map[string]string) *DockerContainer
Labels adds multiple labels
func (*DockerContainer) Name ¶ added in v1.1.5
func (c *DockerContainer) Name(value string) *DockerContainer
Name sets the container name.
func (*DockerContainer) Port ¶ added in v1.1.5
func (c *DockerContainer) Port(external, internal string) *DockerContainer
Port adds a port mapping
func (*DockerContainer) Ports ¶ added in v1.1.5
func (c *DockerContainer) Ports(ports map[string]string) *DockerContainer
Ports adds multiple port mappings
func (*DockerContainer) Run ¶ added in v1.1.5
func (c *DockerContainer) Run() error
Run builds and run command
func (*DockerContainer) Stop ¶ added in v1.1.5
func (c *DockerContainer) Stop() error
Stop and kill container
func (*DockerContainer) Var ¶ added in v1.1.5
func (c *DockerContainer) Var(key, value string) *DockerContainer
Var adds an environment variable
func (*DockerContainer) Vars ¶ added in v1.1.5
func (c *DockerContainer) Vars(vars map[string]string) *DockerContainer
Vars adds multiple environment variables
type HttpUtilsStruct ¶ added in v1.2.106
type HttpUtilsStruct struct { TimeoutSec int // contains filtered or unexported fields }
func HttpUtils ¶ added in v1.2.106
func HttpUtils() *HttpUtilsStruct
HttpUtils is a factory method that acts as a static member
func (*HttpUtilsStruct) New ¶ added in v1.2.106
func (u *HttpUtilsStruct) New(method, url string) *HttpUtilsStruct
func (*HttpUtilsStruct) Send ¶ added in v1.2.106
func (u *HttpUtilsStruct) Send() (*http.Response, error)
func (*HttpUtilsStruct) WithBody ¶ added in v1.2.106
func (u *HttpUtilsStruct) WithBody(body string) *HttpUtilsStruct
func (*HttpUtilsStruct) WithHeader ¶ added in v1.2.106
func (u *HttpUtilsStruct) WithHeader(key, value string) *HttpUtilsStruct
func (*HttpUtilsStruct) WithHeaders ¶ added in v1.2.106
func (u *HttpUtilsStruct) WithHeaders(headers map[string]string) *HttpUtilsStruct
func (*HttpUtilsStruct) WithTimeout ¶ added in v1.2.106
func (u *HttpUtilsStruct) WithTimeout(timeout int) *HttpUtilsStruct
type TokenUtilsStruct ¶ added in v1.2.103
type TokenUtilsStruct struct { }
func TokenUtils ¶ added in v1.1.2
func TokenUtils() *TokenUtilsStruct
TokenUtils is a factory method that acts as a static member
func (*TokenUtilsStruct) CreateApiKey ¶ added in v1.2.103
func (t *TokenUtilsStruct) CreateApiKey(appName string) (string, error)
CreateApiKey generate API Key from application name
func (*TokenUtilsStruct) CreateToken ¶ added in v1.2.103
func (t *TokenUtilsStruct) CreateToken(claims *jwt.RegisteredClaims) (string, error)
CreateToken build JWT token from Token Data structure
func (*TokenUtilsStruct) ParseApiKey ¶ added in v1.2.103
func (t *TokenUtilsStruct) ParseApiKey(apiKey string) (string, error)
ParseApiKey extract application name from API key
func (*TokenUtilsStruct) ParseToken ¶ added in v1.2.103
func (t *TokenUtilsStruct) ParseToken(tokenString string) (*jwt.RegisteredClaims, error)
ParseToken rebuild Token Data structure from JWT token
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
Package cache Cache item implementation Based on https://github.com/ReneKroon/ttlcache
|
Package cache Cache item implementation Based on https://github.com/ReneKroon/ttlcache |
Package cache2 Cache item old implementation Based on https://github.com/ReneKroon/ttlcache
|
Package cache2 Cache item old implementation Based on https://github.com/ReneKroon/ttlcache |