Documentation ¶
Index ¶
- Variables
- func DeserializeJson[T any](data []byte) (T, error)
- func GetTokenClaims(tokenString string, signingKey string) (map[string]interface{}, error)
- func InitLogger() func(*zap.Logger)
- func LoadConfiguration[T Configuration](configFilePath string, config T) error
- func LoadEnvironmentVariables[T Configuration](config T) error
- func Log(lvl zapcore.Level, template string, args ...interface{})
- func LogError(template string, args ...interface{})
- func LogInfo(template string, args ...interface{})
- func LogWarn(template string, args ...interface{})
- func NewBearerToken(signingKey string) ([]byte, error)
- func SerializeJson(data interface{}) (string, error)
- func ValidateBearerToken(tokenString string, signingKey string) (bool, error)
- type Configuration
Constants ¶
This section is empty.
Variables ¶
var ( SLogger *zap.SugaredLogger Logger *zap.Logger )
Functions ¶
func DeserializeJson ¶
func GetTokenClaims ¶ added in v0.5.0
func InitLogger ¶
func LoadConfiguration ¶
func LoadConfiguration[T Configuration](configFilePath string, config T) error
LoadConfiguration loads configuration data from a JSON file into the provided 'config' struct. The 'config' struct should implement the 'Configuration' interface. If a 'ValidateJws' method is present on the 'config' struct, it will be called after loading to ensure configuration validity.
Returns an error if there's an issue reading the file, unmarshalling the JSON, or if validation fails.
func LoadEnvironmentVariables ¶
func LoadEnvironmentVariables[T Configuration](config T) error
LoadEnvironmentVariables loads configuration data from environment variables into the provided 'config' struct. The 'config' struct should implement the 'Configuration' interface. struct tags with the "env" key are used to map environment variables to struct fields. If a 'ValidateJws' method is present on the 'config' struct, it will be called after loading to ensure configuration validity.
Returns an error if there's an issue processing environment variables or if validation fails.
func NewBearerToken ¶ added in v0.5.0
func SerializeJson ¶
Types ¶
type Configuration ¶
type Configuration interface {
Validate() error
}
Configuration represents a type that can be loaded with configuration data and optionally validated.