Documentation
¶
Index ¶
- Constants
- func BoolPtr(b bool) *bool
- func BytePtr(b byte) *byte
- func CalculateOffset(currentPage, pageSize uint32) int32
- func ComparePasswordAndHash(hashPass string, password string) error
- func DurationPtr(d time.Duration) *time.Duration
- func ErrorCode(err error) string
- func ErrorMessage(err error) string
- func ErrorToStatusCode(err error) int
- func Float32Ptr(f float32) *float32
- func Float64Ptr(f float64) *float64
- func GenerateAccessToken(consumerKey string, consumerSecret string) (string, error)
- func GenerateHashPassword(password string, cost int) (string, error)
- func Int32Ptr(i int32) *int32
- func Int64Ptr(i int64) *int64
- func IntPtr(i int) *int
- func InterfaceFloat64(i interface{}) float64
- func PtrToStr(s *string) string
- func RunePtr(r rune) *rune
- func StringPtr(s string) *string
- func StringToFloat64(s string) (float64, error)
- func StringToUint32(s string) (uint32, error)
- func TimePtr(t time.Time) *time.Time
- func Uint32Ptr(i uint32) *uint32
- func Uint64Ptr(i uint64) *uint64
- func UintPtr(i uint) *uint
- type Config
- type EmailSender
- type Error
- type GmailSender
- type JWTMaker
- type PaginationMetadata
- type Payload
Constants ¶
View Source
const ( ALREADY_EXISTS_ERROR = "already_exists" INTERNAL_ERROR = "internal" INVALID_ERROR = "invalid" NOT_FOUND_ERROR = "not_found" NOT_IMPLEMENTED_ERROR = "not_implemented" AUTHENTICATION_ERROR = "authentication" )
Variables ¶
This section is empty.
Functions ¶
func CalculateOffset ¶
func ComparePasswordAndHash ¶
func DurationPtr ¶
DurationPtr returns a pointer to the given time.Duration.
func ErrorMessage ¶
func ErrorToStatusCode ¶
func Float32Ptr ¶
Float32Ptr returns a pointer to the given float32.
func Float64Ptr ¶
Float64Ptr returns a pointer to the given float64.
func GenerateAccessToken ¶
func InterfaceFloat64 ¶
func InterfaceFloat64(i interface{}) float64
transform interface to float64 if error it logs and return 0.00 used to trransform money from db to go type float64
func StringToFloat64 ¶
func StringToUint32 ¶
Types ¶
type Config ¶
type Config struct {
CONFIG_PATH string `mapstructure:"CONFIG_PATH"`
ENVIRONMENT string `mapstructure:"ENVIRONMENT"`
HTTP_PORT string `mapstructure:"HTTP_PORT"`
MYSQL_USER string `mapstructure:"MYSQL_USER"`
MYSQL_PASSWORD string `mapstructure:"MYSQL_PASSWORD"`
MYSQL_DB string `mapstructure:"MYSQL_DB"`
DB_DSN string `mapstructure:"DB_DSN"`
MIGRATION_PATH string `mapstructure:"MIGRATION_PATH"`
TOKEN_DURATION time.Duration `mapstructure:"TOKEN_DURATION"`
PASSWORD_RESET_DURATION time.Duration `mapstructure:"PASSWORD_RESET_DURATION"`
REFRESH_TOKEN_DURATION time.Duration `mapstructure:"REFRESH_TOKEN_DURATION"`
TOKEN_SYMMETRY_KEY string `mapstructure:"TOKEN_SYMMETRY_KEY"`
PASSWORD_COST int `mapstructure:"PASSWORD_COST"`
RSA_PRIVATE_KEY string `mapstructure:"RSA_PRIVATE_KEY"`
RSA_PUBLIC_KEY string `mapstructure:"RSA_PUBLIC_KEY"`
EMAIL_SENDER_PASSWORD string `mapstructure:"EMAIL_SENDER_PASSWORD"`
EMAIL_SENDER_NAME string `mapstructure:"EMAIL_SENDER_NAME"`
EMAIL_SENDER_ADDRESS string `mapstructure:"EMAIL_SENDER_ADDRESS"`
REDIS_ADDRESS string `mapstructure:"REDIS_ADDRESS"`
REDIS_PASSWORD string `mapstructure:"REDIS_PASSWORD"`
MPESA_CONSUMER_KEY string `mapstructure:"MPESA_CONSUMER_KEY"`
MPESA_CONSUMER_SECRET string `mapstructure:"MPESA_CONSUMER_SECRET"`
MPESA_SHORT_CODE string `mapstructure:"MPESA_SHORT_CODE"`
MPESA_PASSKEY string `mapstructure:"MPESA_PASSKEY"`
}
func LoadConfig ¶
Loads app configuration from .env file.
type EmailSender ¶
type EmailSender interface {
SendMail(subject, content string, mimeType string, to, cc, bcc []string, attachmentNames []string, attachmentData [][]byte) error
}
func NewGmailSender ¶
func NewGmailSender(name, fromEmailAddress, fromEmailPassword string) EmailSender
type GmailSender ¶
type GmailSender struct {
// contains filtered or unexported fields
}
type JWTMaker ¶
type JWTMaker struct {
PublicKey *rsa.PublicKey
PrivateKey *rsa.PrivateKey
// contains filtered or unexported fields
}
func NewJWTMaker ¶
func (*JWTMaker) CreateToken ¶
type PaginationMetadata ¶
type PaginationMetadata struct {
PageSize uint32 `json:"pageSize"`
CurrentPage uint32 `json:"currentPage"`
TotalData uint32 `json:"totalData"`
TotalPages uint32 `json:"totalPages"`
FromDate *time.Time `json:"from_date,omitempty"`
ToDate *time.Time `json:"to_date,omitempty"`
}
func CreatePaginationMetadata ¶
func CreatePaginationMetadata(totalData, pageSize, currentPage uint32) PaginationMetadata
Click to show internal directories.
Click to hide internal directories.