Documentation ¶
Index ¶
- Constants
- func BuildCacheKey(key string, identifier string, funcName string, args ...any) string
- func BuildPrefixKey(keys ...string) string
- func CheckIfFileExists(path string) bool
- func ComparedPassword(hashedPassword string, password string) error
- func ConvertInterfaceE(from any, to any) error
- func ConvertInterfaceP(from any, to any)
- func CreateFile(path string) (*os.File, error)
- func CustomError(message string, statusCode int) error
- func CustomErrorWithTrace(err error, message string, statusCode int) error
- func DeferCheck(function func() error)
- func DeleteFile(path string) error
- func DownloadFile(url, filePath string) error
- func EnableCORS(r *chi.Mux)
- func ExecSession(ctx context.Context, client *mongo.Client, fn func(mongo.SessionContext) error) error
- func ExecSessionWithRetry(ctx context.Context, client *mongo.Client, fn func(mongo.SessionContext) error) error
- func ExecTx(ctx context.Context, pgxPool *pgxpool.Pool, fn func(tx pgx.Tx) error) error
- func ExecTxWithRetry(ctx context.Context, pgxPool *pgxpool.Pool, fn func(tx pgx.Tx) error) error
- func Fetch(url string, headers ...map[string]string) (*goquery.Document, error)
- func FetchFile(url string) (*os.File, error)
- func GenerateJsonResponse(w http.ResponseWriter, data interface{}, statusCode int, message string)
- func GetCurrentDir() string
- func GetExt(pathOrFilename string) string
- func HashedPassword(password string) (string, error)
- func ImageUriToBase64(uri string) (string, error)
- func LogAndPanicIfError(err error, message string)
- func LogDebug(message string, fields ...zap.Field)
- func LogError(message string, fields ...zap.Field)
- func LogFatal(message string, fields ...zap.Field)
- func LogIfError(err error)
- func LogInfo(message string, fields ...zap.Field)
- func LogPanic(message string, fields ...zap.Field)
- func Marshal(v any) ([]byte, error)
- func NewDecoder(r io.Reader) *jsoniter.Decoder
- func NewEncoder(w io.Writer) *jsoniter.Encoder
- func PanicAppError(message string, statusCode int)
- func PanicIfAppError(err error, message string, statusCode int)
- func PanicIfAppErrorWithTrace(ctx context.Context, err error, message string, statusCode int)
- func PanicIfError(err error)
- func PanicValidationError(errors []ValidationError, statusCode int)
- func Unmarshal(data []byte, v any) error
- func ValidateBodyPayload(body io.ReadCloser, output interface{})
- func ValidateQueryParamInt(r *http.Request, queryName string) int
- func ValidateStruct(data interface{})
- func ValidateUrlParamUUID(r *http.Request, paramName string) uuid.UUID
- type AppError
- type BaseConfig
- type Pagination
- type ParamType
- type Response
- type ResponseMap
- type ResponseSlice
- type ValidationError
- type ValidationErrors
Constants ¶
View Source
const ( TEST = "test" DEVELOPMENT = "development" STAGING = "staging" PRODUCTION = "production" )
Variables ¶
This section is empty.
Functions ¶
func BuildCacheKey ¶ added in v1.0.35
func BuildPrefixKey ¶ added in v1.0.35
func CheckIfFileExists ¶
func ComparedPassword ¶ added in v1.0.10
func ConvertInterfaceE ¶
func ConvertInterfaceP ¶
func CustomError ¶
func CustomErrorWithTrace ¶
func DeferCheck ¶
func DeferCheck(function func() error)
func DeleteFile ¶
func DownloadFile ¶
func EnableCORS ¶ added in v1.0.6
func EnableCORS(r *chi.Mux)
func ExecSession ¶ added in v1.1.55
func ExecSessionWithRetry ¶ added in v1.1.55
func ExecTxWithRetry ¶ added in v1.1.11
func GenerateJsonResponse ¶ added in v1.0.6
func GenerateJsonResponse(w http.ResponseWriter, data interface{}, statusCode int, message string)
func GetCurrentDir ¶
func GetCurrentDir() string
func HashedPassword ¶ added in v1.0.9
func ImageUriToBase64 ¶ added in v1.1.64
func LogAndPanicIfError ¶
func LogIfError ¶
func LogIfError(err error)
func PanicAppError ¶
func PanicIfAppError ¶
func PanicIfAppErrorWithTrace ¶ added in v1.0.64
func PanicIfError ¶
func PanicIfError(err error)
func PanicValidationError ¶
func PanicValidationError(errors []ValidationError, statusCode int)
func ValidateBodyPayload ¶
func ValidateBodyPayload(body io.ReadCloser, output interface{})
func ValidateQueryParamInt ¶ added in v1.0.6
func ValidateStruct ¶
func ValidateStruct(data interface{})
Types ¶
type BaseConfig ¶
type BaseConfig struct { ServiceName string `mapstructure:"SERVICE_NAME"` ServiceEnv string `mapstructure:"SERVICE_ENV"` ServiceHost string `mapstructure:"SERVICE_HOST"` ServiceHttpPort string `mapstructure:"SERVICE_HTTP_PORT"` ServiceGrpcPort string `mapstructure:"SERVICE_GRPC_PORT"` GcpProjectId string `mapstructure:"GCP_PROJECT_ID"` PubsubDlq string `mapstructure:"PUBSUB_DLQ_TOPIC"` RedisHost string `mapstructure:"REDIS_HOST"` RedisPort string `mapstructure:"REDIS_PORT"` RedisUser string `mapstructure:"REDIS_USER"` RedisPassword string `mapstructure:"REDIS_PASSWORD"` RedisCacheExpire int `mapstructure:"REDIS_DEFAULT_CACHE_EXPIRE"` MongoHost string `mapstructure:"MONGO_HOST"` MongoPort string `mapstructure:"MONGO_PORT"` MongoUser string `mapstructure:"MONGO_USER"` MongoPassword string `mapstructure:"MONGO_PASSWORD"` MongoDb string `mapstructure:"MONGO_DATABASE"` MongoReplicaSet string `mapstructure:"MONGO_REPLICA_SET,default=rs0"` PostgresHost string `mapstructure:"POSTGRES_HOST"` PostgresPort string `mapstructure:"POSTGRES_PORT"` PostgresUser string `mapstructure:"POSTGRES_USER"` PostgresPassword string `mapstructure:"POSTGRES_PASSWORD"` PostgresDb string `mapstructure:"POSTGRES_DATABASE"` ElasticsearchHost []string `mapstructure:"ELASTICSEARCH_HOST"` ElasticsearchUser string `mapstructure:"ELASTICSEARCH_USER"` ElasticsearchPassword string `mapstructure:"ELASTICSEARCH_PASSWORD"` ElasticsearchLogging bool `mapstructure:"ELASTICSEARCH_LOGGING,default=false"` JaegerEnable bool `mapstructure:"JAEGER_ENABLE"` JaegerHost string `mapstructure:"JAEGER_HOST"` JaegerPort string `mapstructure:"JAEGER_PORT"` JaegerLogSpans bool `mapstructure:"JAEGER_LOG_SPANS"` S3Endpoint string `mapstructure:"S3_ENDPOINT"` S3AccessKey string `mapstructure:"S3_ACCESS_KEY"` S3SecretKey string `mapstructure:"S3_SECRET_KEY"` S3Region string `mapstructure:"S3_REGION"` S3PublicBucket string `mapstructure:"S3_PUBLIC_BUCKET"` S3PrivateBucket string `mapstructure:"S3_PRIVATE_BUCKET"` S3PublicUrl string `mapstructure:"S3_PUBLIC_URL"` S3PreSignedExpire time.Duration `mapstructure:"S3_PRESIGNED_EXPIRE"` JwtSecretKey string `mapstructure:"JWT_SECRET_KEY"` JwtAccessTokenExpire time.Duration `mapstructure:"JWT_ACCESS_TOKEN_EXPIRE"` JwtRefreshTokenExpire time.Duration `mapstructure:"JWT_REFRESH_TOKEN_EXPIRE"` KafkaBrokers []string `mapstructure:"KAFKA_BROKERS"` KafkaTopics []string `mapstructure:"KAFKA_TOPICS"` KafkaGroupID string `mapstructure:"KAFKA_GROUP_ID"` KafkaDlqTopic string `mapstructure:"KAFKA_DLQ_TOPIC"` KafkaDlqRetry int `mapstructure:"KAFKA_DLQ_RETRY,default=3"` KafkaAutoCommit bool `mapstructure:"KAFKA_AUTO_COMMIT,default=false"` KafkaAutoTopicCreation bool `mapstructure:"KAFKA_AUTO_TOPIC_CREATION,default=true"` KafkaReplicationFactor int `mapstructure:"KAFKA_REPLICATION_FACTOR,default=1"` }
func CheckAndSetConfig ¶
func CheckAndSetConfig(path string, configName string) *BaseConfig
func LoadBaseConfig ¶
func LoadBaseConfig(path string, configName string) (*BaseConfig, error)
type Pagination ¶ added in v1.0.26
type Pagination[T any] struct { SearchField string `json:"searchField,omitempty"` SearchValue string `json:"searchValue,omitempty"` Limit int `json:"limit,omitempty"` Page int `json:"page,omitempty"` Sort string `json:"sort,omitempty"` TotalRows int `json:"totalRows,omitempty"` TotalPages int `json:"totalPages,omitempty"` Rows []T `json:"rows,omitempty"` }
func Paginate ¶ added in v1.0.26
func Paginate[T any](pagination *Pagination[T], rows []T) *Pagination[T]
func ValidatePagination ¶ added in v1.0.26
func ValidatePagination[T any](r *http.Request) *Pagination[T]
type Response ¶ added in v1.0.6
type Response[T any] struct { StatusCode int `json:"status_code"` Status string `json:"status"` Message string `json:"message"` Data T `json:"data,omitempty"` }
swagger:model Response
type ResponseMap ¶ added in v1.0.6
type ResponseMap struct { StatusCode int `json:"status_code"` Status string `json:"status"` Message string `json:"message"` Data map[string]interface{} `json:"data,omitempty"` }
FOR TESTING PURPOSE
type ResponseSlice ¶ added in v1.0.6
type ResponseSlice struct { StatusCode int `json:"status_code"` Status string `json:"status"` Message string `json:"message"` Data []map[string]interface{} `json:"data,omitempty"` }
FOR TESTING PURPOSE
type ValidationError ¶
type ValidationError struct {
Message string
}
func (*ValidationError) Error ¶
func (ve *ValidationError) Error() string
type ValidationErrors ¶
type ValidationErrors struct { Errors []ValidationError StatusCode int }
func (*ValidationErrors) Error ¶
func (ve *ValidationErrors) Error() string
Click to show internal directories.
Click to hide internal directories.