Documentation
¶
Index ¶
- Constants
- Variables
- func Bind(source any, v any)
- func BindJson(source string, v any)
- func Copy(toValue interface{}, fromValue interface{}) (err error)
- func CopyWithOption(toValue interface{}, fromValue interface{}, opt Option) (err error)
- func FormatMoney(number float64, decimals uint, decPoint, thousandsSep string) string
- func HttpResponseJson(g *gin.Context, i interface{}, err error)
- func IsNil(i interface{}) bool
- func JsonMinify(jsonB []byte) ([]byte, error)
- func LogErr(err error)
- func LogJ(arg interface{})
- func LogJI(arg interface{})
- func ToJson(data interface{}) string
- func ToJsonIndent(data interface{}) string
- type Crypto
- type EncryptWith
- type FieldNameMapping
- type HttpBuilder
- func (h *HttpBuilder) AddHeader(name string, value string)
- func (h *HttpBuilder) Default()
- func (h *HttpBuilder) Get(endPoint string, urlQuery interface{}, body interface{}, ...) (fullUrl, response string, err error)
- func (h *HttpBuilder) GetRequest() *http.Response
- func (h *HttpBuilder) GetResponse() *http.Response
- func (h *HttpBuilder) MultipartEnable()
- func (h *HttpBuilder) Post(endPoint string, body interface{}, option HttpBuilderOptions) (fullUrl, response string, err error)
- func (h *HttpBuilder) SetBasicAuth(username, password string)
- func (h *HttpBuilder) SetClient(client *http.Client)
- func (h *HttpBuilder) SetUrl(url string)
- type HttpBuilderOptions
- type Option
- type RsaEncrypt
- type RsaKeys
- func (r *RsaKeys) Load() (err error)
- func (r *RsaKeys) LoadPrivateKey() (err error)
- func (r *RsaKeys) LoadPublicKey() (err error)
- func (r *RsaKeys) SavePKCS1() (err error)
- func (r *RsaKeys) SavePKCS8() (err error)
- func (r *RsaKeys) SavePrivateKeyPKCS1() (err error)
- func (r *RsaKeys) SavePrivateKeyPKCS8() (err error)
- func (r *RsaKeys) SavePublicKeyPKCS1() (err error)
- func (r *RsaKeys) SavePublicKeyPKIX() (err error)
- func (r *RsaKeys) SetPrivateKey(privateKey []byte) (err error)
- func (r *RsaKeys) SetPrivateKeyString(privateKey string) (err error)
- func (r *RsaKeys) SetPublicKey(publicKey []byte) (err error)
- func (r *RsaKeys) SetPublicKeyString(publicKey string) (err error)
- type RsaSign
- type SagaLogger
- type SagaState
- type TypeConverter
Constants ¶
const ( // Some default converter types for a nicer syntax String string = "" Bool bool = false Int int = 0 Float32 float32 = 0 Float64 float64 = 0 )
These flags define options for tag handling
const ( RSA512 = iota RSA1024 RSA2048 RSA4096 )
Variables ¶
var ( ErrInvalidCopyDestination = errors.New("copy destination must be non-nil and addressable") ErrInvalidCopyFrom = errors.New("copy from must be non-nil and addressable") ErrMapKeyNotMatch = errors.New("map's key type doesn't match") ErrNotSupported = errors.New("not supported") ErrFieldNameTagStartNotUpperCase = errors.New("copier field name tag must be start upper case") )
Functions ¶
func CopyWithOption ¶
CopyWithOption copy with option
func FormatMoney ¶
func HttpResponseJson ¶
func JsonMinify ¶
return a minified JSON input string return an error encountered during minifiying or reading minified bytes
func ToJson ¶
func ToJson(data interface{}) string
Encode json from object to JSON and beautify the output.
func ToJsonIndent ¶ added in v1.4.7
func ToJsonIndent(data interface{}) string
Encode json from object to JSON and beautify the output.
Types ¶
type Crypto ¶
type Crypto struct {
Rsa *RsaKeys
}
Crypto structure
func (*Crypto) Decrypt ¶
func (c *Crypto) Decrypt(encryption *RsaEncrypt) (err error)
Decrypt encrypted message to plain text.
func (*Crypto) Encrypt ¶
func (c *Crypto) Encrypt(encryption *RsaEncrypt) (err error)
func (*Crypto) VerifySign ¶
Verify signature and match with payload.
type FieldNameMapping ¶
type HttpBuilder ¶
type HttpBuilder struct {
// contains filtered or unexported fields
}
Type for saving oy builder params.
func (*HttpBuilder) AddHeader ¶
func (h *HttpBuilder) AddHeader(name string, value string)
Setting up header name and value.
func (*HttpBuilder) Default ¶
func (h *HttpBuilder) Default()
Set http client with default configuration.
func (*HttpBuilder) Get ¶
func (h *HttpBuilder) Get(endPoint string, urlQuery interface{}, body interface{}, option HttpBuilderOptions) (fullUrl, response string, err error)
Get request.
func (*HttpBuilder) GetRequest ¶
func (h *HttpBuilder) GetRequest() *http.Response
func (*HttpBuilder) GetResponse ¶
func (h *HttpBuilder) GetResponse() *http.Response
func (*HttpBuilder) MultipartEnable ¶
func (h *HttpBuilder) MultipartEnable()
func (*HttpBuilder) Post ¶
func (h *HttpBuilder) Post(endPoint string, body interface{}, option HttpBuilderOptions) (fullUrl, response string, err error)
Post request.
func (*HttpBuilder) SetBasicAuth ¶
func (h *HttpBuilder) SetBasicAuth(username, password string)
Set Basic Auth
func (*HttpBuilder) SetClient ¶
func (h *HttpBuilder) SetClient(client *http.Client)
Manual set http builder.
type HttpBuilderOptions ¶
type Option ¶
type Option struct { // setting this value to true will ignore copying zero values of all the fields, including bools, as well as a // struct having all it's fields set to their zero values respectively (see IsZero() in reflect/value.go) IgnoreEmpty bool CaseSensitive bool DeepCopy bool Converters []TypeConverter // Custom field name mappings to copy values with different names in `fromValue` and `toValue` types. // Examples can be found in `copier_field_name_mapping_test.go`. FieldNameMapping []FieldNameMapping }
Option sets copy options
type RsaEncrypt ¶
type RsaEncrypt struct { Hash crypto.Hash Encryption EncryptWith Message []byte Encrypted []byte }
Encryption / decryption setting
func (*RsaEncrypt) FromBase64 ¶
func (r *RsaEncrypt) FromBase64(encrypted string) (err error)
Get encrypted from base64.
type RsaKeys ¶
type RsaKeys struct { PublicKey *rsa.PublicKey PrivateKey *rsa.PrivateKey PrivateKeyFile string PublicKeyFile string }
Handle load and save keys to memory/storage.
func (*RsaKeys) LoadPrivateKey ¶
Load file and setup private key.
func (*RsaKeys) LoadPublicKey ¶
Load file and setup public key.
func (*RsaKeys) SavePrivateKeyPKCS1 ¶
Save PrivateKey to storage in PKCS1.
func (*RsaKeys) SavePrivateKeyPKCS8 ¶
Save PrivateKey to storage in PKCS8 format.
func (*RsaKeys) SavePublicKeyPKCS1 ¶
Save PublicKey to storage in PKCS1.
func (*RsaKeys) SavePublicKeyPKIX ¶
Save PublicKey to storage in PKIX format.
func (*RsaKeys) SetPrivateKey ¶
Parses a PEM encoded private key.
func (*RsaKeys) SetPrivateKeyString ¶
Set the private key string.
func (*RsaKeys) SetPublicKey ¶
Parses a PEM encoded public key.
func (*RsaKeys) SetPublicKeyString ¶
Set the public key string.
type RsaSign ¶
A place for create or load signature ;
func (*RsaSign) FromBase64 ¶
Get signature as base64.
type SagaLogger ¶
func (*SagaLogger) Log ¶
func (sl *SagaLogger) Log(ctx context.Context, tx saga.Transaction) error
type TypeConverter ¶
type TypeConverter struct { SrcType interface{} DstType interface{} Fn func(src interface{}) (dst interface{}, err error) }