Documentation ¶
Index ¶
- Constants
- Variables
- func AnyToString(value interface{}) string
- func BuildAccessToken(header *map[string]interface{}, claims *map[string]interface{}, ...) string
- func BuildEvent(subject EventSubject, eventVerb string, data interface{}, index int64) ([]byte, error)
- func BuildSeries(series int, opt SeriesOptions) string
- func DecodeCommand(encoded string) stringdeprecated
- func DecodeText(encoded string, key []byte) string
- func Decrypt(ciphertext []byte, key []byte) ([]byte, error)
- func Elem[T any](array *[]T, index int, exists *bool) T
- func ElemPtr[T any](array *[]T, index int, exists *bool) *T
- func EncodeCommand(command string) stringdeprecated
- func EncodeText(plainText string, key []byte) string
- func Encrypt(plaintext []byte, key []byte) ([]byte, error)
- func ExecuteAPI(method string, endPoint string, payload []byte, compressed bool, ...) ([]byte, error)
- func GenerateAlpha(length int, lower bool) string
- func GenerateFull(length int) string
- func GenerateSeries(length int) string
- func GenerateText(length int) string
- func GetZero[T FieldTypeConstraint]() T
- func In[T comparable](seek T, list ...T) bool
- func Interpolate(base string, keyValues NameValues) (string, []interface{})
- func IsEmpty[T FieldTypeConstraint](value *T) bool
- func IsNullOrEmpty[T FieldTypeConstraint](value *T) bool
- func IsStringNumeric(value *string) error
- func Itos(value interface{}) string
- func NameValueGet[T constraints.Ordered | bool](nvs NameValues, name string) T
- func NameValueGetPtr[T constraints.Ordered | bool](nvs NameValues, name string) *T
- func NameValuesToInterfaceArray(values NameValues) []interface{}
- func New[T FieldTypeConstraint](value T) *T
- func NonNullComp[T FieldTypeConstraint](param1 *T, param2 *T) int
- func Null[T any](testValue any, defaultValue any) T
- func NullPtr[T any](testValue any, defaultValue any) *T
- func ParseRouteVars(r *http.Request) (Command []string, Key string)
- func SafeMapRead[T any](ptrMap *map[string]T, key string, rw *sync.RWMutex) T
- func SafeMapWrite[T any](ptrMap *map[string]T, key string, value T, rw *sync.RWMutex) bool
- func SetRequestTimeout(timeout int)
- func StripEndingForwardSlash(value string) string
- func StripLeading(value string, offset int) string
- func StripTrailing(value string, length int) string
- func ToInterfaceArray[T FieldTypeConstraint](values T) []interface{}
- func Val[T FieldTypeConstraint](value *T) T
- func ValidateDecimal(value *ssd.Decimal, opts *DecimalValidationOptions) error
- func ValidateEmail(email *string) error
- func ValidateNumeric[T NumericConstraint](value *T, opts *NumericValidationOptions[T]) error
- func ValidateString(value *string, opts *StringValidationOptions) error
- func ValidateTime(value *time.Time, opts *TimeValidationOptions) error
- type CustomPayload
- type CustomVars
- type DecimalValidationOptions
- type Event
- type EventSubject
- type FieldTypeConstraint
- type JWTInfo
- type NameValue
- type NameValues
- func (nvp *NameValues) Bool(name string) (bool, bool)
- func (nvp *NameValues) Bools(name string) []bool
- func (nvp *NameValues) Exists(name string) bool
- func (nvp *NameValues) Float64(name string) (float64, bool)
- func (nvp *NameValues) Float64s(name string) []float64
- func (nvp *NameValues) Int(name string) (int, bool)
- func (nvp *NameValues) Int64(name string) (int64, bool)
- func (nvp *NameValues) Int64s(name string) []int64
- func (nvp *NameValues) Interpolate(base string) (string, []interface{})
- func (nvp *NameValues) Ints(name string) []int
- func (nvp *NameValues) Plain(name string) (interface{}, bool)
- func (nvp *NameValues) PtrBool(name string) (*bool, bool)
- func (nvp *NameValues) PtrFloat64(name string) (*float64, bool)
- func (nvp *NameValues) PtrInt(name string) (*int, bool)
- func (nvp *NameValues) PtrInt64(name string) (*int64, bool)
- func (nvp *NameValues) PtrPlain(name string) (*interface{}, bool)
- func (nvp *NameValues) PtrString(name string) (*string, bool)
- func (nvp *NameValues) SortByKey(keyOrder *[]string) NameValues
- func (nvp *NameValues) String(name string) (string, bool)
- func (nvp *NameValues) Strings(name string) []string
- func (nvp *NameValues) ToInterfaceArray() []interface{}
- type NumericConstraint
- type NumericValidationOptions
- type RequestVars
- func (rv *RequestVars) IsDelete() bool
- func (rv *RequestVars) IsGet() bool
- func (rv *RequestVars) IsHead() bool
- func (rv *RequestVars) IsJSONGood(v interface{}) error
- func (rv *RequestVars) IsOptions() bool
- func (rv *RequestVars) IsPost() bool
- func (rv *RequestVars) IsPostOrPut() bool
- func (rv *RequestVars) IsPut() bool
- type Result
- func (r *Result) AddErr(err error) Result
- func (r *Result) AddError(message string) Result
- func (r *Result) AddErrorf(format string, a ...interface{}) Result
- func (r *Result) AddInfo(message string) Result
- func (r *Result) AddInfof(format string, a ...interface{}) Result
- func (r *Result) AddWarning(message string) Result
- func (r *Result) AddWarningf(format string, a ...interface{}) Result
- func (r *Result) AppendErr(rs Result, err error) Result
- func (r *Result) AppendError(rs Result, message string) Result
- func (r *Result) AppendErrorf(rs Result, format string, a ...interface{}) Result
- func (r *Result) AppendInfo(rs Result, message string) Result
- func (r *Result) AppendInfof(rs Result, format string, a ...interface{}) Result
- func (r *Result) AppendWarning(rs Result, message string) Result
- func (r *Result) AppendWarningf(rs Result, format string, a ...interface{}) Result
- func (r *Result) Error() bool
- func (r *Result) EventID() string
- func (r *Result) Invalid() bool
- func (r *Result) MessageManager() *livenote.LiveNote
- func (r *Result) MessagesToString() string
- func (r *Result) No() bool
- func (r *Result) OK() bool
- func (r *Result) Return(status Status) Result
- func (r *Result) RowsAffectedInfo(rowsaff int64)
- func (r *Result) SetPrefix(pfx string)
- func (r *Result) Stuff(rs Result) Result
- func (r *Result) Valid() bool
- func (r *Result) Yes() bool
- type ResultAny
- type ResultData
- func DeleteJson(endpoint string, headers map[string]string, rw *sync.RWMutex) ResultData
- func ExecuteJsonAPI(method string, endPoint string, payload []byte, compressed bool, ...) (rd ResultData)
- func GetJson(endpoint string, headers map[string]string, rw *sync.RWMutex) ResultData
- func PatchJson(endpoint string, payload []byte, gzipped bool, headers map[string]string, ...) ResultData
- func PostJson(endpoint string, payload []byte, gzipped bool, headers map[string]string, ...) ResultData
- func PutJson(endpoint string, payload []byte, gzipped bool, headers map[string]string, ...) ResultData
- type SeriesOptions
- type Status
- type StringValidationOptions
- type TimeValidationOptions
Constants ¶
const REQUEST_MODIFIED string = "15112023"
const REQUEST_VERSION string = "1.0.0.0"
Variables ¶
var (
ErrRVNoBody = errors.New(`the request has no payload`)
)
Errors
Functions ¶
func AnyToString ¶
func AnyToString(value interface{}) string
AnyToString converts any variable to string
func BuildAccessToken ¶
func BuildAccessToken(header *map[string]interface{}, claims *map[string]interface{}, secretkey string) string
BuildAccessToken builds a JWT token
func BuildEvent ¶
func BuildEvent(subject EventSubject, eventVerb string, data interface{}, index int64) ([]byte, error)
BuildEvent builds an event based on the inputs
func BuildSeries ¶
func BuildSeries(series int, opt SeriesOptions) string
BuildSeries builds series based on options
func DecodeCommand
deprecated
DecodeCommand decodes an encrypted and base64-encoded text for the receiving page
It uses the library key to decrypt the string after the input has been decoded from base64 ¶
Deprecated: Use the EncodeText and DecodeText functions with a 32-bit application-defined key
func DecodeText ¶
DecodeText decodes an encypted base64-encoded text with a key and returns a decrypted string
func Elem ¶
Elem returns the element of an array as specified by the index
If the index exceeds the length of an array, it will return a non-nil value of the type. To monitor if the element exists, define a boolean value in the exists parameter
This function requires version 1.18+
func ElemPtr ¶
ElemPtr returns a pointer to the element of an array as specified by the index
If the index exceeds the length of an array, it will return a non-nil value of the type. To monitor if the element exists, define a boolean value in the exists parameter
This function requires version 1.18+
func EncodeCommand
deprecated
func EncodeText ¶
EncodeText encodes plain text with a key and returns an encrypted and base64-encoded string
func ExecuteAPI ¶
func ExecuteAPI(method string, endPoint string, payload []byte, compressed bool, header map[string]string, timeOut int) ([]byte, error)
ExecuteAPI wraps http operation that change or read data and returns a byte array
func GenerateAlpha ¶
GenerateAlpha generates a random text that uses the 26 letters of the alphabet
func GenerateFull ¶
GenerateFull generates a random text that uses all letters of the alphabet, in both cases including numbers
func GenerateSeries ¶
GenerateSeries generates random numbers
func GenerateText ¶
GenerateText generates a random text that uses all letters of the alphabet, in both cases not including numbers
func GetZero ¶
func GetZero[T FieldTypeConstraint]() T
GetZero gets the zero value of the types defined as constraints.Ordered, time.Time and shopspring/decimal
This function requires version 1.18+
func In ¶
func In[T comparable](seek T, list ...T) bool
In checks if the seek parameter is in the list parameter
func Interpolate ¶
func Interpolate(base string, keyValues NameValues) (string, []interface{})
Interpolate interpolates string with the name value pairs
func IsEmpty ¶
func IsEmpty[T FieldTypeConstraint](value *T) bool
IsNullOrEmpty checks for emptiness of a pointer variable ignoring nullity Currently supported data types are the ones in the constraints.Ordered, time.Time, bool and shopspring/decimal
This function requires version 1.18+
func IsNullOrEmpty ¶
func IsNullOrEmpty[T FieldTypeConstraint](value *T) bool
IsNullOrEmpty checks for nullity and emptiness of a pointer variable Currently supported data types are the ones in the constraints.Ordered, time.Time, bool and shopspring/decimal
This function requires version 1.18+
func IsStringNumeric ¶
IsStringNumeric checks if a string is numeric
func Itos ¶
func Itos(value interface{}) string
Itos is a shortcut to AnyToString. I means Interface
func NameValueGet ¶
func NameValueGet[T constraints.Ordered | bool](nvs NameValues, name string) T
NameValueGet gets the value from the collection of NameValues by name
This function requires version 1.18+
func NameValueGetPtr ¶
func NameValueGetPtr[T constraints.Ordered | bool](nvs NameValues, name string) *T
NameValueGetPtr gets the value from the collection of NameValues by name as pointer
This function requires version 1.18+
func NameValuesToInterfaceArray ¶
func NameValuesToInterfaceArray(values NameValues) []interface{}
NameValuesToInterfaceArray converts name values to interface array
func New ¶
func New[T FieldTypeConstraint](value T) *T
New initializes a variable and returns a pointer of its type Currently supported data types are the ones in the constraints.Ordered, time.Time, bool and shopspring/decimal
This function requires version 1.18+
func NonNullComp ¶
func NonNullComp[T FieldTypeConstraint](param1 *T, param2 *T) int
NonNullComp compares two parameters when both are not nil. When one or both of the parameters is nil, the function returns -1 When the parameters are equal, the function returns 0. Else it returns 1
This function requires version 1.18+
func Null ¶
Null accepts a value to test and the default value if it fails. It returns a non-pointer value of T.
This function requires version 1.18+
func NullPtr ¶
NullPtr accepts a value to test and the default value if it fails. It returns a pointer value of T.
This function requires version 1.18+
func ParseRouteVars ¶
ParseRouteVars parses custom routes from a mux handler
func SafeMapRead ¶
SafeMapRead allows reading maps by locking it, preventing the library from crashing
func SafeMapWrite ¶
SafeMapWrite allows writing to maps by locking, preventing the library from crashing
func SetRequestTimeout ¶
func SetRequestTimeout(timeout int)
SetRequestTimeOut sets the new timeout value
func StripEndingForwardSlash ¶
StripEndingForwardSlash removes the ending forward slash of a string
func StripLeading ¶
StripLeading strips string of leading characters by an offset
func StripTrailing ¶
StripTrailing strips string of trailing characters after the length
func ToInterfaceArray ¶
func ToInterfaceArray[T FieldTypeConstraint](values T) []interface{}
ToInterfaceArray converts a value to interface array
This function requires version 1.18+
func Val ¶
func Val[T FieldTypeConstraint](value *T) T
Val gets the value of a pointer in order Currently supported data types are the ones in the constraints.Ordered, time.Time, bool and shopspring/decimal
This function requires version 1.18+
func ValidateDecimal ¶
func ValidateDecimal(value *ssd.Decimal, opts *DecimalValidationOptions) error
ValidateDecimal validates a decimal input against decimal validation options
func ValidateEmail ¶
ValidateEmail - validate an e-mail address
func ValidateNumeric ¶
func ValidateNumeric[T NumericConstraint](value *T, opts *NumericValidationOptions[T]) error
ValidateNumeric validates a numeric input against numeric validation options
func ValidateString ¶
func ValidateString(value *string, opts *StringValidationOptions) error
ValidateString validates an input string against the string validation options
func ValidateTime ¶
func ValidateTime(value *time.Time, opts *TimeValidationOptions) error
ValidateTime validates an input time against the time validation options
Types ¶
type CustomPayload ¶
type CustomPayload struct { jwt.Payload UserName string `json:"usr,omitempty"` // Username payload for JWT Domain string `json:"dom,omitempty"` // Domain payload for JWT ApplicationID string `json:"app,omitempty"` // Application payload for JWT DeviceID string `json:"dev,omitempty"` // Device id payload for JWT TenantID string `json:"tnt,omitempty"` // Tenant id payload for JWT }
CustomPayload - payload for JWT
type CustomVars ¶
type CustomVars struct { Command []string // Commands represents the sub-paths in the URL request Key string // The key of the the request QueryString NameValues // The query string values of the URL request HasQueryString bool // Indicates that the URL request has a query string FormData NameValues // The form values associated with the URL request, usually appear when the method is POST and PUT HasFormData bool // Indicates that the URL request has form data IsMultipart bool // Indicates that the URL request is a multi part request DecodedCommand NameValues // Decoded commands from an encrypted values represented by q query string }
CustomVars - command struct
func (CustomVars) FirstCommand ¶
func (cv CustomVars) FirstCommand() string
FirstCommand - get first command from route
func (CustomVars) GetCommand ¶
func (cv CustomVars) GetCommand(index uint) (exists bool, value string)
GetCommand - get command by index
func (CustomVars) LastCommand ¶
func (cv CustomVars) LastCommand() string
LastCommand - get third command from route
func (CustomVars) SecondCommand ¶
func (cv CustomVars) SecondCommand() string
SecondCommand - get second command from route
func (CustomVars) ThirdCommand ¶
func (cv CustomVars) ThirdCommand() string
ThirdCommand - get third command from route
type DecimalValidationOptions ¶
type DecimalValidationOptions struct { Null bool // Allow null. Default: false, will raise an error if the decimal is null Empty bool // Allow zero decimal. Default: false, will raise an error if the decimal is zero Min *ssd.Decimal // Minimum decimal value. Default: nil Max *ssd.Decimal // Maximum decimal value. Default: nil Extended []func(value *ssd.Decimal) error }
type Event ¶
type Event struct { Index int64 `json:"index,omitempty"` // Optional. Index of this data to return to later Subject string `json:"subject,omitempty"` // Subject of the event Data interface{} `json:"data,omitempty"` // Data of the event }
Event contains the address and the event data
type EventSubject ¶
type EventSubject struct { Application string // Application. This would form as the first segment Service string // Service. This would form as the second segment Module string // Module. This would form as the last segment }
EventSubject is a struct to describe the subject event
func GetEventModuleMatch ¶
func GetEventModuleMatch(module string, evtChans []EventSubject) *EventSubject
GetEventModuleMatch seeks the list of events by module
func GetEventSubjectMatch ¶
func GetEventSubjectMatch(subject string, evtChans []EventSubject) *EventSubject
GetEventSubjectMatch seeks the list of event by subject
func NewEventSubjectBase ¶
func NewEventSubjectBase(application, service, module string) EventSubject
NewEventSubjectBase properly creates a new event base.
func (EventSubject) ToString ¶
func (ec EventSubject) ToString(eventVerb *string) string
ToString converts an EventSubject to a readable string
type FieldTypeConstraint ¶
type JWTInfo ¶
type JWTInfo struct { ApplicationID string // Application ID from the JWT token Audience []string // Audience intended by the token DeviceID string // The device id where the token came from Domain string // The application domain that the token is intended for Raw string // Raw JWT token TenantID string // Tenant ID from the JWT token UserName string // User account authenticated and produced the token Valid bool // Indicates that the request has a valid JWT token }
JWTInfo contains the information about JWT
type NameValues ¶
NameValues - a struct to manage value structs
func ParseQueryString ¶
func ParseQueryString(qs *string) NameValues
ParseQueryString parses the query string into a column value
func SortByKey ¶
func SortByKey(values *NameValues, keyOrder *[]string) NameValues
SortByKey reorders keys and values based on a keyOrder array sequence
func (*NameValues) Bool ¶
func (nvp *NameValues) Bool(name string) (bool, bool)
Bool returns the name value as boolean. It automatically convers 'true', 'yes', '1', '-1' and 'on' to boolean The second argument returns the existence.
func (*NameValues) Bools ¶
func (nvp *NameValues) Bools(name string) []bool
Bools returns the values as a boolean array
func (*NameValues) Exists ¶
func (nvp *NameValues) Exists(name string) bool
Exists checks if the key or name exists. It returns the index of the element if found, -1 if not found.
func (*NameValues) Float64 ¶
func (nvp *NameValues) Float64(name string) (float64, bool)
Float64 returns the name value as float64. The second argument returns the existence.
func (*NameValues) Float64s ¶
func (nvp *NameValues) Float64s(name string) []float64
Float64s returns the values as a float64 array
func (*NameValues) Int ¶
func (nvp *NameValues) Int(name string) (int, bool)
Int returns the name value as int. The second argument returns the existence.
func (*NameValues) Int64 ¶
func (nvp *NameValues) Int64(name string) (int64, bool)
Int64 returns the name value as int64. The second argument returns the existence.
func (*NameValues) Int64s ¶
func (nvp *NameValues) Int64s(name string) []int64
Int64s returns the values as an int64 array
func (*NameValues) Interpolate ¶
func (nvp *NameValues) Interpolate(base string) (string, []interface{})
Interpolate - interpolate string with values from with base string
func (*NameValues) Ints ¶
func (nvp *NameValues) Ints(name string) []int
Ints returns the values as an int array
func (*NameValues) Plain ¶
func (nvp *NameValues) Plain(name string) (interface{}, bool)
Plain returns the name value as interface{}. The second argument returns the existence.
func (*NameValues) PtrBool ¶
func (nvp *NameValues) PtrBool(name string) (*bool, bool)
PtrBool returns the name value as pointer to bool. The second argument returns the existence.
func (*NameValues) PtrFloat64 ¶
func (nvp *NameValues) PtrFloat64(name string) (*float64, bool)
PtrFloat64 returns the name value as pointer to int64. The second argument returns the existence.
func (*NameValues) PtrInt ¶
func (nvp *NameValues) PtrInt(name string) (*int, bool)
PtrInt returns the name value as pointer to int. The second argument returns the existence.
func (*NameValues) PtrInt64 ¶
func (nvp *NameValues) PtrInt64(name string) (*int64, bool)
PtrInt64 returns the name value as pointer to int64. The second argument returns the existence.
func (*NameValues) PtrPlain ¶
func (nvp *NameValues) PtrPlain(name string) (*interface{}, bool)
PtrPlain returns the name value as pointer to interface{}. The second argument returns the existence.
func (*NameValues) PtrString ¶
func (nvp *NameValues) PtrString(name string) (*string, bool)
PtrString returns the name value as pointer to string. The second argument returns the existence.
func (*NameValues) SortByKey ¶
func (nvp *NameValues) SortByKey(keyOrder *[]string) NameValues
SortByKey sort name values by key order array
func (*NameValues) String ¶
func (nvp *NameValues) String(name string) (string, bool)
String returns the name value as string. The second argument returns the existence.
func (*NameValues) Strings ¶
func (nvp *NameValues) Strings(name string) []string
Strings returns the values as a string array
func (*NameValues) ToInterfaceArray ¶
func (nvp *NameValues) ToInterfaceArray() []interface{}
ToInterfaceArray - converts name values to interface array
type NumericConstraint ¶
type NumericConstraint interface { constraints.Integer | constraints.Float }
type NumericValidationOptions ¶
type NumericValidationOptions[T NumericConstraint] struct { Null bool // Allow null. Default: false, will raise an error if the time is null Empty bool // Allow zero time Default: false, will raise an error if the time is zero Min T // Minimum time. Default: nil Max T // Maximum time. Default: nil Extended []func(value *T) error }
type RequestVars ¶
type RequestVars struct { Body []byte // The body of the request Cookies map[string]string // Cookies included in the request HasBody bool // Indicates that the request has a body Method string // Method of the request Variables CustomVars // Variables included in the request Token *JWTInfo // Access token }
RequestVars - contains necessary request variables
func GetRequestVars ¶
GetRequestVars requests variables and return JWT validation result
func GetRequestVarsOnly ¶
func GetRequestVarsOnly(r *http.Request) RequestVars
GetRequestVarsOnly get request variables
func (*RequestVars) IsDelete ¶
func (rv *RequestVars) IsDelete() bool
IsDelete is a shortcut method to check if the request is a DELETE
func (*RequestVars) IsGet ¶
func (rv *RequestVars) IsGet() bool
IsGet - a shortcut method to check if the request is a GET
func (*RequestVars) IsHead ¶
func (rv *RequestVars) IsHead() bool
IsHead is a shortcut method to check if the request is a HEAD
func (*RequestVars) IsJSONGood ¶
func (rv *RequestVars) IsJSONGood(v interface{}) error
IsJSONGood checks if the request has body and attempts to marshal to Json
func (*RequestVars) IsOptions ¶
func (rv *RequestVars) IsOptions() bool
IsOptions is a shortcut method to check if the request is OPTIONS
func (*RequestVars) IsPost ¶
func (rv *RequestVars) IsPost() bool
IsPost is a shortcut method to check if the request is a POST
func (*RequestVars) IsPostOrPut ¶
func (rv *RequestVars) IsPostOrPut() bool
IsPostOrPut is a shortcut method to check if the request is a POST or PUT
func (*RequestVars) IsPut ¶
func (rv *RequestVars) IsPut() bool
IsPut is a shortcut method to check if the request is a PUT
type Result ¶
type Result struct { Messages []string `json:"messages"` // Accumulated messages as a result from Add methods. Do not append messages using append() Status string `json:"status"` // OK, ERROR, VALID or any status Operation string `json:"operation,omitempty"` // Name of the operation / function that returned the result TaskID *string `json:"task_id,omitempty"` // ID of the request and of the result WorkerID *string `json:"worker_id,omitempty"` // ID of the worker that processed the data FocusControl *string `json:"focus_control,omitempty"` // Control to focus when error was activated Page *int `json:"page,omitempty"` // Current Page PageCount *int `json:"page_count,omitempty"` // Page Count PageSize *int `json:"page_size,omitempty"` // Page Size Tag *interface{} `json:"tag,omitempty"` // Miscellaneous result MessagePrefix string `json:"prefix,omitempty"` // Prefix of the message to return // contains filtered or unexported fields }
Result - standard result structure
func InitResult ¶
InitResult - initialize result for API query. This is the recommended initialization of this object. The variadic arguments of std.NameValue data type will be intepreted as follows:
To set the initial status, set NameValue.Name to "status" and set NameValue.Value to a valid status if the value is not a valid status, it will be ignored */
To set a message prefix, set NameValue.Name to "prefix" and set NameValue.Value to a string value.
To add a message, set NameValue.Name to "message" and set NameValue.Value to a valid message. Depending on the current status (default is EXCEPTION), the message type is automatically set to that type
func (*Result) AddWarning ¶
AddWarning - adds a warning message and returns itself
func (*Result) AddWarningf ¶
AddWarningf adds a formatted warning message and returns itself
func (*Result) AppendErr ¶
AppendErr copies the messages of the Result parameter and append an error message
func (*Result) AppendError ¶
AppendError copies the messages of the Result parameter and append the current message
func (*Result) AppendErrorf ¶
AppendErrorf copies the messages of the Result parameter and append a formatted error message
func (*Result) AppendInfo ¶
AppendInfo copies the messages of the Result parameter and append the current message
func (*Result) AppendInfof ¶
AppendInfof copies the messages of the Result parameter and append a formatted information message
func (*Result) AppendWarning ¶
AppendWarning copies the messages of the Result parameter and append the current message
func (*Result) AppendWarningf ¶
AppendWarningf copies the messages of the Result parameter and append a formatted warning message
func (*Result) MessageManager ¶
MessageManager returns the internal message manager
func (*Result) MessagesToString ¶
ToString adds a formatted error message and returns itself
func (*Result) RowsAffectedInfo ¶
RowsAffectedInfo - a function to simplify adding information for rows affected
type ResultData ¶
type ResultData struct { Result Data json.RawMessage `json:"data"` }
ResultData - a result structure and a JSON raw message
func DeleteJson ¶
DeleteJson wraps http.Delete with custom result
func ExecuteJsonAPI ¶
func ExecuteJsonAPI(method string, endPoint string, payload []byte, compressed bool, header map[string]string, timeOut int, rw *sync.RWMutex) (rd ResultData)
ExecuteJsonAPI wraps http operation that change or read data and returns a custom result
func PatchJson ¶
func PatchJson(endpoint string, payload []byte, gzipped bool, headers map[string]string, rw *sync.RWMutex) ResultData
PatchJson wraps http.Patch with custom result
type SeriesOptions ¶
type StringValidationOptions ¶
type StringValidationOptions struct { Empty bool // Allow empty string. Default: false, will raise an error if the string is empty Null bool // Allow null. Default: false, will raise an error if the string is null Min int // Minimum length. Default: 0 Max int // Maximum length. Default: 0 NoSpaces bool // Do not allow spaces in the string. Default: false. Setting to true will raise an error if the string has spaces Extended []func(value *string) error }
type TimeValidationOptions ¶
type TimeValidationOptions struct { Null bool // Allow null. Default: false, will raise an error if the time is null Empty bool // Allow zero time Default: false, will raise an error if the time is zero Min *time.Time // Minimum time. Default: nil Max *time.Time // Maximum time. Default: nil DateOnly bool // Compare dates only. Default: false Extended []func(value *time.Time) error }