Documentation
¶
Index ¶
- Constants
- Variables
- func CaptureError(ctx IContext, level sentry.Level, err error, args ...interface{})
- func CaptureErrorEcho(ctx echo.Context, level sentry.Level, err error)
- func CaptureHTTPError(ctx IHTTPContext, level sentry.Level, err error, args ...interface{})
- func CaptureSimpleError(level sentry.Level, err error, args ...interface{})
- func Core(options *HTTPContextOptions) func(next echo.HandlerFunc) echo.HandlerFunc
- func Crash(err error) error
- func ErrorToJson(err error) (m map[string]jsonErr)
- func Fake(a interface{}) error
- func GetBodyString(c echo.Context) []byte
- func HTTPMiddlewareCORS(options *HTTPContextOptions) echo.MiddlewareFunc
- func HTTPMiddlewareCreateLogger(next echo.HandlerFunc) echo.HandlerFunc
- func HTTPMiddlewareFromCache(key func(IHTTPContext) string) echo.MiddlewareFunc
- func HTTPMiddlewareHandleError(env IENV) echo.HTTPErrorHandler
- func HTTPMiddlewareHandleNotFound(c echo.Context) error
- func HTTPMiddlewareRateLimit(options *HTTPContextOptions) echo.MiddlewareFunc
- func HTTPMiddlewareRecoverWithConfig(env IENV, config middleware.RecoverConfig) echo.MiddlewareFunc
- func HTTPMiddlewareRequestID() echo.MiddlewareFunc
- func IsError(err error) bool
- func NewHTTPServer(options *HTTPContextOptions) *echo.Echo
- func Paginate(db *gorm.DB, model interface{}, options *models.PageOptions) (*models.PageResponse, error)
- func Recover(textError string)
- func SetSearch(db *gorm.DB, keywordCondition *KeywordConditionWrapper) *gorm.DB
- func SetSearchSimple(db *gorm.DB, q string, columns []string) *gorm.DB
- func StartHTTPServer(e *echo.Echo, env IENV)
- func WithHTTPContext(h HandlerFunc) echo.HandlerFunc
- type ArchiveByteBody
- type ArchiverOptions
- type BaseValidator
- func (b *BaseValidator) AddValidator(errs ...*Valid)
- func (b *BaseValidator) Error() IError
- func (b *BaseValidator) GetValidator() *Valid
- func (b *BaseValidator) IsArrayBetween(array interface{}, min int, max int, fieldPath string) (bool, *IValidMessage)
- func (b *BaseValidator) IsArrayMax(array interface{}, size int, fieldPath string) (bool, *IValidMessage)
- func (b *BaseValidator) IsArrayMin(array interface{}, size int, fieldPath string) (bool, *IValidMessage)
- func (b *BaseValidator) IsArraySize(array interface{}, size int, fieldPath string) (bool, *IValidMessage)
- func (b *BaseValidator) IsBase64(field *string, fieldPath string) (bool, *IValidMessage)
- func (b *BaseValidator) IsBoolRequired(value interface{}, fieldPath string) (bool, *IValidMessage)
- func (b *BaseValidator) IsCustom(customFunc func() (bool, *IValidMessage)) (bool, *IValidMessage)
- func (b *BaseValidator) IsDateTime(input *string, fieldPath string) (bool, *IValidMessage)
- func (b *BaseValidator) IsDateTimeAfter(input *string, after *string, fieldPath string) (bool, *IValidMessage)
- func (b *BaseValidator) IsDateTimeBefore(input *string, before *string, fieldPath string) (bool, *IValidMessage)
- func (b *BaseValidator) IsEmail(field *string, fieldPath string) (bool, *IValidMessage)
- func (b *BaseValidator) IsExists(ctx IContext, field *string, table string, column string, fieldPath string) (bool, *IValidMessage)
- func (b *BaseValidator) IsExistsWithCondition(ctx IContext, table string, condition map[string]interface{}, fieldPath string) (bool, *IValidMessage)
- func (b *BaseValidator) IsFloatNumberBetween(field *float64, min float64, max float64, fieldPath string) (bool, *IValidMessage)
- func (b *BaseValidator) IsFloatNumberMax(field *float64, max float64, fieldPath string) (bool, *IValidMessage)
- func (b *BaseValidator) IsFloatNumberMin(field *float64, min float64, fieldPath string) (bool, *IValidMessage)
- func (b *BaseValidator) IsIP(field *string, fieldPath string) (bool, *IValidMessage)
- func (b *BaseValidator) IsJSONArray(field *json.RawMessage, fieldPath string) (bool, *IValidMessage)
- func (b *BaseValidator) IsJSONArrayMax(field *json.RawMessage, max int, fieldPath string) (bool, *IValidMessage)
- func (b *BaseValidator) IsJSONArrayMin(field *json.RawMessage, min int, fieldPath string) (bool, *IValidMessage)
- func (b *BaseValidator) IsJSONBoolPathRequired(json *json.RawMessage, path string, fieldPath string) (bool, *IValidMessage)
- func (b *BaseValidator) IsJSONObject(field *json.RawMessage, fieldPath string) (bool, *IValidMessage)
- func (b *BaseValidator) IsJSONObjectNotEmpty(field *json.RawMessage, fieldPath string) (bool, *IValidMessage)
- func (b *BaseValidator) IsJSONObjectPath(j *json.RawMessage, path string, fieldPath string) (bool, *IValidMessage)
- func (b *BaseValidator) IsJSONPathRequireNotEmpty(j *json.RawMessage, path string, fieldPath string) (bool, *IValidMessage)
- func (b *BaseValidator) IsJSONPathRequired(j *json.RawMessage, path string, fieldPath string) (bool, *IValidMessage)
- func (b *BaseValidator) IsJSONPathStrIn(json *json.RawMessage, path string, rules string, fieldPath string) (bool, *IValidMessage)
- func (b *BaseValidator) IsJSONRequired(field *json.RawMessage, fieldPath string) (bool, *IValidMessage)
- func (b *BaseValidator) IsJSONStrPathRequired(json *json.RawMessage, path string, fieldPath string) (bool, *IValidMessage)
- func (b *BaseValidator) IsMongoExistsWithCondition(ctx IContext, table string, filter interface{}, fieldPath string) (bool, *IValidMessage)
- func (b *BaseValidator) IsMongoStrUnique(ctx IContext, table string, filter interface{}, fieldPath string) (bool, *IValidMessage)
- func (b *BaseValidator) IsNotEmptyObjectRequired(value interface{}, fieldPath string) (bool, *IValidMessage)
- func (b *BaseValidator) IsNumberBetween(field *int64, min int64, max int64, fieldPath string) (bool, *IValidMessage)
- func (b *BaseValidator) IsNumberMax(field *int64, max int64, fieldPath string) (bool, *IValidMessage)
- func (b *BaseValidator) IsNumberMin(field *int64, min int64, fieldPath string) (bool, *IValidMessage)
- func (b *BaseValidator) IsRequired(field interface{}, fieldPath string) (bool, *IValidMessage)
- func (b *BaseValidator) IsRequiredArray(array interface{}, fieldPath string) (bool, *IValidMessage)
- func (b *BaseValidator) IsStrIn(input *string, rules string, fieldPath string) (bool, *IValidMessage)
- func (b *BaseValidator) IsStrMax(input *string, size int, fieldPath string) (bool, *IValidMessage)
- func (b *BaseValidator) IsStrMin(input *string, size int, fieldPath string) (bool, *IValidMessage)
- func (b *BaseValidator) IsStrRequired(field *string, fieldPath string) (bool, *IValidMessage)
- func (b *BaseValidator) IsStrUnique(ctx IContext, field *string, table string, column string, except string, ...) (bool, *IValidMessage)
- func (b *BaseValidator) IsStringContain(field *string, substr string, fieldPath string) (bool, *IValidMessage)
- func (b *BaseValidator) IsStringEndWith(field *string, substr string, fieldPath string) (bool, *IValidMessage)
- func (b *BaseValidator) IsStringLowercase(field *string, fieldPath string) (bool, *IValidMessage)
- func (b *BaseValidator) IsStringNotContain(field *string, substr string, fieldPath string) (bool, *IValidMessage)
- func (b *BaseValidator) IsStringNumber(field *string, fieldPath string) (bool, *IValidMessage)
- func (b *BaseValidator) IsStringNumberMin(field *string, min int64, fieldPath string) (bool, *IValidMessage)
- func (b *BaseValidator) IsStringStartWith(field *string, substr string, fieldPath string) (bool, *IValidMessage)
- func (b *BaseValidator) IsStringUppercase(field *string, fieldPath string) (bool, *IValidMessage)
- func (b *BaseValidator) IsTime(input *string, fieldPath string) (bool, *IValidMessage)
- func (b *BaseValidator) IsTimeAfter(input *string, after *string, fieldPath string) (bool, *IValidMessage)
- func (b *BaseValidator) IsTimeBefore(input *string, before *string, fieldPath string) (bool, *IValidMessage)
- func (b *BaseValidator) IsTimeRequired(field *time.Time, fieldPath string) (bool, *IValidMessage)
- func (b *BaseValidator) IsURL(field *string, fieldPath string) (bool, *IValidMessage)
- func (b *BaseValidator) LoopJSONArray(j *json.RawMessage) []interface{}
- func (b *BaseValidator) Merge(errs ...*Valid) IError
- func (b *BaseValidator) Must(condition bool, msg *IValidMessage) bool
- func (b *BaseValidator) SetPrefix(prefix string)
- type ContextOptions
- type ContextUser
- type CronjobContext
- type CronjobContextOptions
- type Database
- type DatabaseCache
- type DatabaseMongo
- type ENVConfig
- type ENVType
- func (e ENVType) All() map[string]string
- func (e ENVType) Bool(key string) bool
- func (e ENVType) Config() *ENVConfig
- func (e ENVType) Int(key string) int
- func (e ENVType) IsDev() bool
- func (e ENVType) IsMock() bool
- func (e ENVType) IsProd() bool
- func (e ENVType) IsTest() bool
- func (e ENVType) String(key string) string
- type Error
- type FieldError
- type File
- type HTTPContext
- func (c *HTTPContext) BindOnly(i interface{}) IError
- func (c *HTTPContext) BindWithValidate(ctx IValidateContext) IError
- func (c *HTTPContext) BindWithValidateJWT(ctx IValidateContext) IError
- func (c *HTTPContext) BindWithValidateMessage(ctx IValidateContext) IError
- func (c *HTTPContext) GetJWT() string
- func (c *HTTPContext) GetMessage() string
- func (c *HTTPContext) GetPageOptions() *models.PageOptions
- func (c *HTTPContext) GetPageOptionsWithOptions(options *PageOptionsOptions) *models.PageOptions
- func (c *HTTPContext) GetSignature() string
- func (c HTTPContext) GetUserAgent() *user_agent.UserAgent
- func (c *HTTPContext) Log() ILogger
- func (c *HTTPContext) NewError(err error, errorType IError, args ...interface{}) IError
- func (c *HTTPContext) WithSaveCache(data interface{}, key string, duration time.Duration) interface{}
- type HTTPContextOptions
- type HandlerFunc
- type IArchiver
- type ICSV
- type ICSVOptions
- type ICache
- type IContext
- type ICronjobContext
- type IENV
- type IEmail
- type IError
- func DBErrorToIError(err error) IError
- func MockIError(args mock.Arguments, index int) IError
- func NewValidatorFields(fields interface{}) IError
- func RequesterToStruct(desc interface{}, requester func() (*RequestResponse, error)) IError
- func RequesterToStructPagination(items interface{}, options *models.PageOptions, ...) (*models.PageResponse, IError)
- type IFMC
- type IFMCMessage
- type IFMCPayload
- type IFile
- type IHTTPContext
- type ILogger
- type IMQ
- type IMQContext
- type IMongoDB
- type IMongoDBHelper
- type IMongoIndexBatch
- type IMongoIndexer
- type IRequester
- type IS3
- type ISeed
- type IValidMessage
- type IValidate
- type IValidateContext
- type KeywordCondition
- type KeywordConditionWrapper
- type KeywordOptions
- type KeywordType
- type Logger
- func (logger *Logger) Debug(args ...interface{})
- func (logger *Logger) DebugWithSkip(skip int, args ...interface{})
- func (logger *Logger) Error(message error, args ...interface{})
- func (logger *Logger) ErrorWithSkip(skip int, message error, args ...interface{})
- func (logger *Logger) Info(args ...interface{})
- func (logger *Logger) Warn(args ...interface{})
- type MQ
- type MQConsumeOptions
- type MQContext
- type MQContextOptions
- type MQPublishOptions
- type MongoDB
- func (m MongoDB) Close()
- func (m MongoDB) Count(coll string, filter interface{}, opts ...*options.CountOptions) (int64, error)
- func (m MongoDB) Create(coll string, document interface{}, opts ...*options.InsertOneOptions) (*mongo.InsertOneResult, error)
- func (m MongoDB) CreateIndex(coll string, models []mongo.IndexModel, opts ...*options.CreateIndexesOptions) ([]string, error)
- func (m MongoDB) DB() *mongo.Database
- func (m MongoDB) DeleteMany(coll string, filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)
- func (m MongoDB) DeleteOne(coll string, filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)
- func (m MongoDB) Drop(coll string) error
- func (m MongoDB) DropAll(coll string, opts ...*options.DropIndexesOptions) (*MongoDropIndexResult, error)
- func (m MongoDB) DropIndex(coll string, name string, opts ...*options.DropIndexesOptions) (*MongoDropIndexResult, error)
- func (m MongoDB) Find(dest interface{}, coll string, filter interface{}, ...) error
- func (m MongoDB) FindAggregate(dest interface{}, coll string, pipeline interface{}, ...) error
- func (m MongoDB) FindAggregateOne(dest interface{}, coll string, pipeline interface{}, ...) error
- func (m MongoDB) FindAggregatePagination(dest interface{}, coll string, pipeline interface{}, ...) (*models.PageResponse, error)
- func (m MongoDB) FindOne(dest interface{}, coll string, filter interface{}, ...) error
- func (m MongoDB) FindOneAndDelete(coll string, filter interface{}, opts ...*options.FindOneAndDeleteOptions) error
- func (m MongoDB) FindOneAndUpdate(dest interface{}, coll string, filter interface{}, update interface{}, ...) error
- func (m MongoDB) FindPagination(dest interface{}, coll string, filter interface{}, ...) (*models.PageResponse, error)
- func (m MongoDB) Helper() IMongoDBHelper
- func (m MongoDB) ListIndex(coll string, opts ...*options.ListIndexesOptions) ([]MongoListIndexResult, error)
- func (m MongoDB) UpdateOne(coll string, filter interface{}, update interface{}, ...) (*mongo.UpdateResult, error)
- type MongoDropIndexResult
- type MongoFilterOptions
- type MongoIndexer
- type MongoListIndexResult
- type MongoLookupOptions
- type PageOptionsOptions
- type RequestResponse
- type Requester
- func (r Requester) Create(method consts.RequesterMethodType, url string, body interface{}, ...) (*RequestResponse, error)
- func (r Requester) Delete(url string, options *RequesterOptions) (*RequestResponse, error)
- func (r Requester) Get(url string, options *RequesterOptions) (*RequestResponse, error)
- func (r Requester) Patch(url string, body interface{}, options *RequesterOptions) (*RequestResponse, error)
- func (r Requester) Post(url string, body interface{}, options *RequesterOptions) (*RequestResponse, error)
- func (r Requester) Put(url string, body interface{}, options *RequesterOptions) (*RequestResponse, error)
- type RequesterOptions
- type S3Config
- type Seeder
- type UploadOptions
- type Valid
- func (v *Valid) Add(err ...error)
- func (v *Valid) Error() string
- func (v *Valid) GetCode() string
- func (v *Valid) GetMessage() interface{}
- func (v *Valid) GetStatus() int
- func (v *Valid) JSON() interface{}
- func (v *Valid) Must(x bool, msg *IValidMessage) bool
- func (v *Valid) OriginalError() error
- func (v *Valid) OriginalErrorMessage() string
- func (v *Valid) Valid() IError
- type ValidError
- type Validator
Constants ¶
View Source
const ( MustMatch KeywordType = "must_match" Wildcard KeywordType = "wildcard" And KeywordCondition = "and" Or KeywordCondition = "or" )
View Source
const ( DatabaseDriverPOSTGRES = "postgres" DatabaseDriverMSSQL = "mssql" DatabaseDriverOracle = "oracle" DatabaseDriverMYSQL = "mysql" )
View Source
const DateFormat = "2006-01-02 15:04:05"
View Source
const EnvFileName = ".env"
View Source
const EnvTestFileName = "test.env"
View Source
const TimeFormat = "15:04:05"
View Source
const TimeFormatRegex = "^([01]?[0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]$"
Variables ¶
View Source
var ArrayBetweenM = func(field string, min int, max int) *IValidMessage { return &IValidMessage{ Name: field, Code: "INVALID_ARRAY_SIZE_BETWEEN", Message: fmt.Sprintf("The %v field field must contain between %v and %v item(s)", field, min, max), Data: map[string]interface{}{ "min": min, "max": max, }, } }
View Source
var ArrayM = func(field string) *IValidMessage { return &IValidMessage{ Name: field, Code: "INVALID_ARRAY", Message: "The " + field + " field must be array format", } }
View Source
var ArrayMaxM = func(field string, max int) *IValidMessage { return &IValidMessage{ Name: field, Code: "INVALID_ARRAY_SIZE_MAX", Message: fmt.Sprintf("The %v field must not be greater than %v item(s)", field, max), Data: max, } }
View Source
var ArrayMinM = func(field string, min int) *IValidMessage { return &IValidMessage{ Name: field, Code: "INVALID_ARRAY_SIZE_MIN", Message: fmt.Sprintf("The %v field required at least %v items", field, min), Data: min, } }
View Source
var ArraySizeM = func(field string, size int) *IValidMessage { return &IValidMessage{ Name: field, Code: "INVALID_ARRAY_SIZE", Message: fmt.Sprintf("The %v field must contain %v item(s)", field, size), Data: size, } }
View Source
var Base64M = func(field string) *IValidMessage { return &IValidMessage{ Name: field, Code: "BASE64", Message: "The " + field + " must be base64 format", } }
View Source
var BooleanM = func(field string) *IValidMessage { return &IValidMessage{ Name: field, Code: "INVALID_TYPE", Message: "The " + field + " field must be boolean", } }
View Source
var DateTimeAfterM = func(field string, after string) *IValidMessage { return &IValidMessage{ Name: field, Code: "INVALID_DATE_TIME", Message: fmt.Sprintf("The "+field+` field must be after "%s"`, after), } }
View Source
var DateTimeBeforeM = func(field string, before string) *IValidMessage { return &IValidMessage{ Name: field, Code: "INVALID_DATE_TIME", Message: fmt.Sprintf("The "+field+` field must be before "%s"`, before), } }
View Source
var DateTimeM = func(field string) *IValidMessage { return &IValidMessage{ Name: field, Code: "INVALID_DATE_TIME", Message: "The " + field + ` field must be in "yyyy-MM-dd HH:mm:ss" format`, } }
View Source
var EmailM = func(field string) *IValidMessage { return &IValidMessage{ Name: field, Code: "INVALID_EMAIL", Message: fmt.Sprintf("The %v field must be Email Address", field), } }
View Source
var EmailServiceParserError = Error{ Status: http.StatusInternalServerError, Code: "EMAIL_PARSING_ERROR", Message: "can not parse email", }
View Source
var EmailServiceSendFailed = Error{ Status: http.StatusBadGateway, Code: "SEND_EMAIL_ERROR", Message: "can not send email", }
View Source
var ExistsM = func(field string) *IValidMessage { return &IValidMessage{ Name: field, Code: "NOT_EXISTS", Message: "The " + field + " field's value is not exists", } }
View Source
var FCMServiceConnectError = Error{ Status: http.StatusBadGateway, Code: "FCM_CONNECT_ERROR", Message: "failure to connect to fcm service", }
View Source
var FCMServiceSendError = Error{ Status: http.StatusBadGateway, Code: "FCM_SEND_ERROR", Message: "failure to send notification", }
View Source
var FloatNumberBetweenM = func(field string, min float64, max float64) *IValidMessage { return &IValidMessage{ Name: field, Code: "INVALID_NUMBER_MIN", Message: fmt.Sprintf("The %v field must be from %v to %v", field, min, max), } }
View Source
var FloatNumberMaxM = func(field string, size float64) *IValidMessage { return &IValidMessage{ Name: field, Code: "INVALID_NUMBER_MAX", Message: fmt.Sprintf("The %v field must be less than or equal %v", field, size), Data: size, } }
View Source
var FloatNumberMinM = func(field string, size float64) *IValidMessage { return &IValidMessage{ Name: field, Code: "INVALID_NUMBER_MIN", Message: fmt.Sprintf("The %v field must be greater than or equal %v", field, size), Data: size, } }
View Source
var IPM = func(field string) *IValidMessage { return &IValidMessage{ Name: field, Code: "INVALID_IP", Message: fmt.Sprintf("The %v field must be IP Address", field), } }
View Source
var InM = func(field string, rules string) *IValidMessage { split := strings.Split(rules, "|") msg := strings.Join(split, ", ") return &IValidMessage{ Name: field, Code: "INVALID_VALUE_NOT_IN_LIST", Message: "The " + field + " field must be one of " + msg, Data: split, } }
View Source
var JSONArrayM = func(field string) *IValidMessage { return &IValidMessage{ Name: field, Code: "INVALID_JSON_ARRAY", Message: "The " + field + " field must be array format", } }
View Source
var JSONM = func(field string) *IValidMessage { return &IValidMessage{ Name: field, Code: "INVALID_JSON", Message: "The " + field + " field must be json", } }
View Source
var JSONObjectEmptyM = func(field string) *IValidMessage { return &IValidMessage{ Name: field, Code: "INVALID_JSON", Message: "The " + field + " field cannot be empty object", } }
View Source
var JSONObjectM = func(field string) *IValidMessage { return &IValidMessage{ Name: field, Code: "INVALID_JSON", Message: "The " + field + " field must be json object", } }
View Source
var MQError = Error{ Status: http.StatusInternalServerError, Code: "MQ_ERROR", Message: "mq internal error"}
View Source
var NumberBetweenM = func(field string, min int64, max int64) *IValidMessage { return &IValidMessage{ Name: field, Code: "INVALID_NUMBER_MIN", Message: fmt.Sprintf("The %v field must be from %v to %v", field, min, max), } }
View Source
var NumberM = func(field string) *IValidMessage { return &IValidMessage{ Name: field, Code: "INVALID_TYPE", Message: "The " + field + " field cannot parse to number", } }
View Source
var NumberMaxM = func(field string, size int64) *IValidMessage { return &IValidMessage{ Name: field, Code: "INVALID_NUMBER_MAX", Message: fmt.Sprintf("The %v field must be less than or equal %v", field, size), Data: size, } }
View Source
var NumberMinM = func(field string, size int64) *IValidMessage { return &IValidMessage{ Name: field, Code: "INVALID_NUMBER_MIN", Message: fmt.Sprintf("The %v field must be greater than or equal %v", field, size), Data: size, } }
View Source
var ObjectEmptyM = func(field string) *IValidMessage { return &IValidMessage{ Name: field, Code: "INVALID_TYPE", Message: "The " + field + " field cannot be empty object", } }
View Source
var RequiredM = func(field string) *IValidMessage { return &IValidMessage{ Name: field, Code: "REQUIRED", Message: "The " + field + " field is required", } }
View Source
var StrMaxM = func(field string, max int) *IValidMessage { return &IValidMessage{ Name: field, Code: "INVALID_STRING_SIZE_MAX", Message: fmt.Sprintf("The %v field must not be longer than %v character(s)", field, max), Data: max, } }
View Source
var StrMinM = func(field string, min int) *IValidMessage { return &IValidMessage{ Name: field, Code: "INVALID_STRING_SIZE_MIN", Message: fmt.Sprintf("The %v field must not be shorter than %v character(s)", field, min), Data: min, } }
View Source
var StringContainM = func(field string, substr string) *IValidMessage { return &IValidMessage{ Name: field, Code: "INVALID_STRING_CONTAIN", Message: fmt.Sprintf("The %v field must contain %v", field, substr), Data: substr, } }
View Source
var StringEndWithM = func(field string, substr string) *IValidMessage { return &IValidMessage{ Name: field, Code: "INVALID_STRING_END_WITH", Message: fmt.Sprintf("The %v field must end with %v", field, substr), Data: substr, } }
View Source
var StringLowercaseM = func(field string) *IValidMessage { return &IValidMessage{ Name: field, Code: "INVALID_STRING_LOWERCASE", Message: fmt.Sprintf("The %v field must be lowercase", field), } }
View Source
var StringM = func(field string) *IValidMessage { return &IValidMessage{ Name: field, Code: "INVALID_TYPE", Message: "The " + field + " field must be string", } }
View Source
var StringNotContainM = func(field string, substr string) *IValidMessage { return &IValidMessage{ Name: field, Code: "INVALID_STRING_NOT_CONTAIN", Message: fmt.Sprintf("The %v field must not contain %v", field, substr), Data: substr, } }
View Source
var StringStartWithM = func(field string, substr string) *IValidMessage { return &IValidMessage{ Name: field, Code: "INVALID_STRING_START_WITH", Message: fmt.Sprintf("The %v field must start with %v", field, substr), Data: substr, } }
View Source
var StringUppercaseM = func(field string) *IValidMessage { return &IValidMessage{ Name: field, Code: "INVALID_STRING_UPPERCASE", Message: fmt.Sprintf("The %v field must be uppercase", field), } }
View Source
var TimeAfterM = func(field string, after string) *IValidMessage { return &IValidMessage{ Name: field, Code: "INVALID_TIME", Message: fmt.Sprintf("The "+field+` field must be after "%s"`, after), } }
View Source
var TimeBeforeM = func(field string, before string) *IValidMessage { return &IValidMessage{ Name: field, Code: "INVALID_TIME", Message: fmt.Sprintf("The "+field+` field must be before "%s"`, before), } }
View Source
var TimeM = func(field string) *IValidMessage { return &IValidMessage{ Name: field, Code: "INVALID_TIME", Message: "The " + field + ` field must be in "HH:mm:ss"" format`, } }
View Source
var URLM = func(field string) *IValidMessage { return &IValidMessage{ Name: field, Code: "INVALID_URL", Message: "The " + field + " field is not url", } }
View Source
var UniqueM = func(field string) *IValidMessage { return &IValidMessage{ Name: field, Code: "UNIQUE", Message: "The " + field + " field's value already exists", } }
Functions ¶
func CaptureError ¶ added in v1.2.0
func CaptureErrorEcho ¶ added in v1.2.0
func CaptureHTTPError ¶ added in v1.2.0
func CaptureHTTPError(ctx IHTTPContext, level sentry.Level, err error, args ...interface{})
func CaptureSimpleError ¶ added in v1.2.0
func Core ¶ added in v1.2.0
func Core(options *HTTPContextOptions) func(next echo.HandlerFunc) echo.HandlerFunc
func ErrorToJson ¶ added in v1.2.0
func GetBodyString ¶ added in v1.2.0
func HTTPMiddlewareCORS ¶ added in v1.2.0
func HTTPMiddlewareCORS(options *HTTPContextOptions) echo.MiddlewareFunc
func HTTPMiddlewareCreateLogger ¶ added in v1.2.0
func HTTPMiddlewareCreateLogger(next echo.HandlerFunc) echo.HandlerFunc
func HTTPMiddlewareFromCache ¶ added in v1.2.0
func HTTPMiddlewareFromCache(key func(IHTTPContext) string) echo.MiddlewareFunc
func HTTPMiddlewareHandleError ¶ added in v1.2.0
func HTTPMiddlewareHandleError(env IENV) echo.HTTPErrorHandler
func HTTPMiddlewareHandleNotFound ¶ added in v1.2.0
func HTTPMiddlewareRateLimit ¶ added in v1.2.0
func HTTPMiddlewareRateLimit(options *HTTPContextOptions) echo.MiddlewareFunc
func HTTPMiddlewareRecoverWithConfig ¶ added in v1.2.0
func HTTPMiddlewareRecoverWithConfig(env IENV, config middleware.RecoverConfig) echo.MiddlewareFunc
func HTTPMiddlewareRequestID ¶ added in v1.2.0
func HTTPMiddlewareRequestID() echo.MiddlewareFunc
func NewHTTPServer ¶ added in v1.2.0
func NewHTTPServer(options *HTTPContextOptions) *echo.Echo
func Paginate ¶ added in v1.2.0
func Paginate(db *gorm.DB, model interface{}, options *models.PageOptions) (*models.PageResponse, error)
func SetSearch ¶ added in v1.2.0
func SetSearch(db *gorm.DB, keywordCondition *KeywordConditionWrapper) *gorm.DB
func SetSearchSimple ¶ added in v1.2.0
func StartHTTPServer ¶ added in v1.2.0
func WithHTTPContext ¶ added in v1.2.0
func WithHTTPContext(h HandlerFunc) echo.HandlerFunc
Types ¶
type ArchiveByteBody ¶ added in v1.2.0
type ArchiverOptions ¶ added in v1.2.0
type ArchiverOptions struct {
}
type BaseValidator ¶ added in v1.2.0
type BaseValidator struct {
// contains filtered or unexported fields
}
func (*BaseValidator) AddValidator ¶ added in v1.2.0
func (b *BaseValidator) AddValidator(errs ...*Valid)
func (*BaseValidator) Error ¶ added in v1.2.0
func (b *BaseValidator) Error() IError
func (*BaseValidator) GetValidator ¶ added in v1.2.0
func (b *BaseValidator) GetValidator() *Valid
func (*BaseValidator) IsArrayBetween ¶ added in v1.2.0
func (b *BaseValidator) IsArrayBetween(array interface{}, min int, max int, fieldPath string) (bool, *IValidMessage)
func (*BaseValidator) IsArrayMax ¶ added in v1.2.0
func (b *BaseValidator) IsArrayMax(array interface{}, size int, fieldPath string) (bool, *IValidMessage)
func (*BaseValidator) IsArrayMin ¶ added in v1.2.0
func (b *BaseValidator) IsArrayMin(array interface{}, size int, fieldPath string) (bool, *IValidMessage)
func (*BaseValidator) IsArraySize ¶ added in v1.2.0
func (b *BaseValidator) IsArraySize(array interface{}, size int, fieldPath string) (bool, *IValidMessage)
func (*BaseValidator) IsBase64 ¶ added in v1.2.0
func (b *BaseValidator) IsBase64(field *string, fieldPath string) (bool, *IValidMessage)
func (*BaseValidator) IsBoolRequired ¶ added in v1.2.0
func (b *BaseValidator) IsBoolRequired(value interface{}, fieldPath string) (bool, *IValidMessage)
func (*BaseValidator) IsCustom ¶ added in v1.2.0
func (b *BaseValidator) IsCustom(customFunc func() (bool, *IValidMessage)) (bool, *IValidMessage)
func (*BaseValidator) IsDateTime ¶ added in v1.2.0
func (b *BaseValidator) IsDateTime(input *string, fieldPath string) (bool, *IValidMessage)
func (*BaseValidator) IsDateTimeAfter ¶ added in v1.2.0
func (b *BaseValidator) IsDateTimeAfter(input *string, after *string, fieldPath string) (bool, *IValidMessage)
func (*BaseValidator) IsDateTimeBefore ¶ added in v1.2.0
func (b *BaseValidator) IsDateTimeBefore(input *string, before *string, fieldPath string) (bool, *IValidMessage)
func (*BaseValidator) IsEmail ¶ added in v1.2.0
func (b *BaseValidator) IsEmail(field *string, fieldPath string) (bool, *IValidMessage)
func (*BaseValidator) IsExists ¶ added in v1.2.0
func (b *BaseValidator) IsExists(ctx IContext, field *string, table string, column string, fieldPath string) (bool, *IValidMessage)
func (*BaseValidator) IsExistsWithCondition ¶ added in v1.2.0
func (b *BaseValidator) IsExistsWithCondition( ctx IContext, table string, condition map[string]interface{}, fieldPath string, ) (bool, *IValidMessage)
func (*BaseValidator) IsFloatNumberBetween ¶ added in v1.2.0
func (b *BaseValidator) IsFloatNumberBetween(field *float64, min float64, max float64, fieldPath string) (bool, *IValidMessage)
func (*BaseValidator) IsFloatNumberMax ¶ added in v1.2.0
func (b *BaseValidator) IsFloatNumberMax(field *float64, max float64, fieldPath string) (bool, *IValidMessage)
func (*BaseValidator) IsFloatNumberMin ¶ added in v1.2.0
func (b *BaseValidator) IsFloatNumberMin(field *float64, min float64, fieldPath string) (bool, *IValidMessage)
func (*BaseValidator) IsIP ¶ added in v1.2.0
func (b *BaseValidator) IsIP(field *string, fieldPath string) (bool, *IValidMessage)
func (*BaseValidator) IsJSONArray ¶ added in v1.2.0
func (b *BaseValidator) IsJSONArray(field *json.RawMessage, fieldPath string) (bool, *IValidMessage)
func (*BaseValidator) IsJSONArrayMax ¶ added in v1.2.0
func (b *BaseValidator) IsJSONArrayMax(field *json.RawMessage, max int, fieldPath string) (bool, *IValidMessage)
func (*BaseValidator) IsJSONArrayMin ¶ added in v1.2.0
func (b *BaseValidator) IsJSONArrayMin(field *json.RawMessage, min int, fieldPath string) (bool, *IValidMessage)
func (*BaseValidator) IsJSONBoolPathRequired ¶ added in v1.2.0
func (b *BaseValidator) IsJSONBoolPathRequired(json *json.RawMessage, path string, fieldPath string) (bool, *IValidMessage)
func (*BaseValidator) IsJSONObject ¶ added in v1.2.0
func (b *BaseValidator) IsJSONObject(field *json.RawMessage, fieldPath string) (bool, *IValidMessage)
func (*BaseValidator) IsJSONObjectNotEmpty ¶ added in v1.2.0
func (b *BaseValidator) IsJSONObjectNotEmpty(field *json.RawMessage, fieldPath string) (bool, *IValidMessage)
func (*BaseValidator) IsJSONObjectPath ¶ added in v1.2.0
func (b *BaseValidator) IsJSONObjectPath(j *json.RawMessage, path string, fieldPath string) (bool, *IValidMessage)
func (*BaseValidator) IsJSONPathRequireNotEmpty ¶ added in v1.2.0
func (b *BaseValidator) IsJSONPathRequireNotEmpty(j *json.RawMessage, path string, fieldPath string) (bool, *IValidMessage)
func (*BaseValidator) IsJSONPathRequired ¶ added in v1.2.0
func (b *BaseValidator) IsJSONPathRequired(j *json.RawMessage, path string, fieldPath string) (bool, *IValidMessage)
func (*BaseValidator) IsJSONPathStrIn ¶ added in v1.2.0
func (b *BaseValidator) IsJSONPathStrIn(json *json.RawMessage, path string, rules string, fieldPath string) (bool, *IValidMessage)
func (*BaseValidator) IsJSONRequired ¶ added in v1.2.0
func (b *BaseValidator) IsJSONRequired(field *json.RawMessage, fieldPath string) (bool, *IValidMessage)
func (*BaseValidator) IsJSONStrPathRequired ¶ added in v1.2.0
func (b *BaseValidator) IsJSONStrPathRequired(json *json.RawMessage, path string, fieldPath string) (bool, *IValidMessage)
func (*BaseValidator) IsMongoExistsWithCondition ¶ added in v1.2.0
func (b *BaseValidator) IsMongoExistsWithCondition( ctx IContext, table string, filter interface{}, fieldPath string, ) (bool, *IValidMessage)
func (*BaseValidator) IsMongoStrUnique ¶ added in v1.2.0
func (b *BaseValidator) IsMongoStrUnique(ctx IContext, table string, filter interface{}, fieldPath string) (bool, *IValidMessage)
func (*BaseValidator) IsNotEmptyObjectRequired ¶ added in v1.2.0
func (b *BaseValidator) IsNotEmptyObjectRequired(value interface{}, fieldPath string) (bool, *IValidMessage)
func (*BaseValidator) IsNumberBetween ¶ added in v1.2.0
func (b *BaseValidator) IsNumberBetween(field *int64, min int64, max int64, fieldPath string) (bool, *IValidMessage)
func (*BaseValidator) IsNumberMax ¶ added in v1.2.0
func (b *BaseValidator) IsNumberMax(field *int64, max int64, fieldPath string) (bool, *IValidMessage)
func (*BaseValidator) IsNumberMin ¶ added in v1.2.0
func (b *BaseValidator) IsNumberMin(field *int64, min int64, fieldPath string) (bool, *IValidMessage)
func (*BaseValidator) IsRequired ¶ added in v1.2.0
func (b *BaseValidator) IsRequired(field interface{}, fieldPath string) (bool, *IValidMessage)
func (*BaseValidator) IsRequiredArray ¶ added in v1.2.0
func (b *BaseValidator) IsRequiredArray(array interface{}, fieldPath string) (bool, *IValidMessage)
func (*BaseValidator) IsStrIn ¶ added in v1.2.0
func (b *BaseValidator) IsStrIn(input *string, rules string, fieldPath string) (bool, *IValidMessage)
func (*BaseValidator) IsStrMax ¶ added in v1.2.0
func (b *BaseValidator) IsStrMax(input *string, size int, fieldPath string) (bool, *IValidMessage)
func (*BaseValidator) IsStrMin ¶ added in v1.2.0
func (b *BaseValidator) IsStrMin(input *string, size int, fieldPath string) (bool, *IValidMessage)
func (*BaseValidator) IsStrRequired ¶ added in v1.2.0
func (b *BaseValidator) IsStrRequired(field *string, fieldPath string) (bool, *IValidMessage)
func (*BaseValidator) IsStrUnique ¶ added in v1.2.0
func (b *BaseValidator) IsStrUnique(ctx IContext, field *string, table string, column string, except string, fieldPath string) (bool, *IValidMessage)
func (*BaseValidator) IsStringContain ¶ added in v1.2.0
func (b *BaseValidator) IsStringContain(field *string, substr string, fieldPath string) (bool, *IValidMessage)
func (*BaseValidator) IsStringEndWith ¶ added in v1.2.0
func (b *BaseValidator) IsStringEndWith(field *string, substr string, fieldPath string) (bool, *IValidMessage)
func (*BaseValidator) IsStringLowercase ¶ added in v1.2.0
func (b *BaseValidator) IsStringLowercase(field *string, fieldPath string) (bool, *IValidMessage)
func (*BaseValidator) IsStringNotContain ¶ added in v1.2.0
func (b *BaseValidator) IsStringNotContain(field *string, substr string, fieldPath string) (bool, *IValidMessage)
func (*BaseValidator) IsStringNumber ¶ added in v1.2.0
func (b *BaseValidator) IsStringNumber(field *string, fieldPath string) (bool, *IValidMessage)
func (*BaseValidator) IsStringNumberMin ¶ added in v1.2.0
func (b *BaseValidator) IsStringNumberMin(field *string, min int64, fieldPath string) (bool, *IValidMessage)
func (*BaseValidator) IsStringStartWith ¶ added in v1.2.0
func (b *BaseValidator) IsStringStartWith(field *string, substr string, fieldPath string) (bool, *IValidMessage)
func (*BaseValidator) IsStringUppercase ¶ added in v1.2.0
func (b *BaseValidator) IsStringUppercase(field *string, fieldPath string) (bool, *IValidMessage)
func (*BaseValidator) IsTime ¶ added in v1.2.0
func (b *BaseValidator) IsTime(input *string, fieldPath string) (bool, *IValidMessage)
func (*BaseValidator) IsTimeAfter ¶ added in v1.2.0
func (b *BaseValidator) IsTimeAfter(input *string, after *string, fieldPath string) (bool, *IValidMessage)
func (*BaseValidator) IsTimeBefore ¶ added in v1.2.0
func (b *BaseValidator) IsTimeBefore(input *string, before *string, fieldPath string) (bool, *IValidMessage)
func (*BaseValidator) IsTimeRequired ¶ added in v1.2.0
func (b *BaseValidator) IsTimeRequired(field *time.Time, fieldPath string) (bool, *IValidMessage)
func (*BaseValidator) IsURL ¶ added in v1.2.0
func (b *BaseValidator) IsURL(field *string, fieldPath string) (bool, *IValidMessage)
func (*BaseValidator) LoopJSONArray ¶ added in v1.2.0
func (b *BaseValidator) LoopJSONArray(j *json.RawMessage) []interface{}
func (*BaseValidator) Merge ¶ added in v1.2.0
func (b *BaseValidator) Merge(errs ...*Valid) IError
func (*BaseValidator) Must ¶ added in v1.2.0
func (b *BaseValidator) Must(condition bool, msg *IValidMessage) bool
func (*BaseValidator) SetPrefix ¶ added in v1.2.0
func (b *BaseValidator) SetPrefix(prefix string)
type ContextOptions ¶ added in v1.2.0
type ContextUser ¶ added in v1.2.0
type CronjobContext ¶ added in v1.2.0
type CronjobContext struct {
IContext
// contains filtered or unexported fields
}
func (CronjobContext) AddJob ¶ added in v1.2.0
func (c CronjobContext) AddJob(job *gocron.Scheduler, handlerFunc func(ctx ICronjobContext) error)
func (CronjobContext) Job ¶ added in v1.2.0
func (c CronjobContext) Job() *gocron.Scheduler
func (CronjobContext) Start ¶ added in v1.2.0
func (c CronjobContext) Start()
type CronjobContextOptions ¶ added in v1.2.0
type CronjobContextOptions struct {
ContextOptions *ContextOptions
TimeLocation *time.Location
}
type Database ¶ added in v1.2.0
type Database struct {
Driver string
Name string
Host string
User string
Password string
Port string
// contains filtered or unexported fields
}
func NewDatabase ¶ added in v1.2.0
func NewDatabaseWithConfig ¶ added in v1.2.0
type DatabaseCache ¶ added in v1.2.0
func NewCache ¶ added in v1.2.0
func NewCache(env *ENVConfig) *DatabaseCache
func (DatabaseCache) Connect ¶ added in v1.2.0
func (r DatabaseCache) Connect() (ICache, error)
type DatabaseMongo ¶ added in v1.2.0
func NewDatabaseMongo ¶ added in v1.2.0
func NewDatabaseMongo(env *ENVConfig) *DatabaseMongo
func (*DatabaseMongo) Connect ¶ added in v1.2.0
func (db *DatabaseMongo) Connect() (IMongoDB, error)
Connect to connect Database
type ENVConfig ¶ added in v1.1.0
type ENVConfig struct {
LogLevel logrus.Level
LogHost string `mapstructure:"log_host"`
LogPort string `mapstructure:"log_port"`
Host string `mapstructure:"host"`
ENV string `mapstructure:"env"`
Service string `mapstructure:"service"`
SentryDSN string `mapstructure:"sentry_dsn"`
DBDriver string `mapstructure:"db_driver"`
DBHost string `mapstructure:"db_host"`
DBName string `mapstructure:"db_name"`
DBUser string `mapstructure:"db_user"`
DBPassword string `mapstructure:"db_password"`
DBPort string `mapstructure:"db_port"`
DBMongoHost string `mapstructure:"db_mongo_host"`
DBMongoName string `mapstructure:"db_mongo_name"`
DBMongoUserName string `mapstructure:"db_mongo_username"`
DBMongoPassword string `mapstructure:"db_mongo_password"`
DBMongoPort string `mapstructure:"db_mongo_port"`
MQHost string `mapstructure:"mq_host"`
MQUser string `mapstructure:"mq_user"`
MQPassword string `mapstructure:"mq_password"`
MQPort string `mapstructure:"mq_port"`
CachePort string `mapstructure:"cache_port"`
CacheHost string `mapstructure:"cache_host"`
ABCIEndpoint string `mapstructure:"abci_endpoint"`
DIDMethodDefault string `mapstructure:"did_method_default"`
DIDKeyTypeDefault string `mapstructure:"did_key_type_default"`
WinRMHost string `mapstructure:"winrm_host"`
WinRMUser string `mapstructure:"winrm_user"`
WinRMPassword string `mapstructure:"winrm_password"`
S3Endpoint string `mapstructure:"s3_endpoint"`
S3AccessKey string `mapstructure:"s3_access_key"`
S3SecretKey string `mapstructure:"s3_secret_key"`
S3Bucket string `mapstructure:"s3_bucket"`
S3Region string `mapstructure:"s3_region"`
S3IsHTTPS bool `mapstructure:"s3_https"`
EmailServer string `mapstructure:"email_server"`
EmailPort int `mapstructure:"email_port"`
EmailUsername string `mapstructure:"email_username"`
EmailPassword string `mapstructure:"email_password"`
EmailSender string `mapstructure:"email_sender"`
FirebaseCredential string `mapstructure:"firebase_credential"`
}
type ENVType ¶ added in v1.1.0
type ENVType struct {
// contains filtered or unexported fields
}
type Error ¶ added in v1.2.0
type Error struct {
Status int `json:"-"`
Code string `json:"code"`
Message interface{} `json:"message"`
Data interface{} `json:"-"`
Fields interface{} `json:"fields,omitempty"`
// contains filtered or unexported fields
}
func (Error) GetMessage ¶ added in v1.2.0
func (c Error) GetMessage() interface{}
func (Error) OriginalError ¶ added in v1.2.0
type FieldError ¶ added in v1.2.0
type FieldError struct {
Code string `json:"code"`
Message string `json:"message"`
Fields interface{} `json:"fields,omitempty"`
}
func (FieldError) Error ¶ added in v1.2.0
func (f FieldError) Error() string
func (FieldError) GetCode ¶ added in v1.2.0
func (f FieldError) GetCode() string
func (FieldError) GetMessage ¶ added in v1.2.0
func (f FieldError) GetMessage() interface{}
func (FieldError) GetStatus ¶ added in v1.2.0
func (FieldError) GetStatus() int
func (FieldError) JSON ¶ added in v1.2.0
func (f FieldError) JSON() interface{}
func (FieldError) OriginalError ¶ added in v1.2.0
func (f FieldError) OriginalError() error
func (FieldError) OriginalErrorMessage ¶ added in v1.2.0
func (f FieldError) OriginalErrorMessage() string
type HTTPContext ¶ added in v1.2.0
func (*HTTPContext) BindOnly ¶ added in v1.2.0
func (c *HTTPContext) BindOnly(i interface{}) IError
func (*HTTPContext) BindWithValidate ¶ added in v1.2.0
func (c *HTTPContext) BindWithValidate(ctx IValidateContext) IError
func (*HTTPContext) BindWithValidateJWT ¶ added in v1.2.0
func (c *HTTPContext) BindWithValidateJWT(ctx IValidateContext) IError
func (*HTTPContext) BindWithValidateMessage ¶ added in v1.2.0
func (c *HTTPContext) BindWithValidateMessage(ctx IValidateContext) IError
func (*HTTPContext) GetJWT ¶ added in v1.2.0
func (c *HTTPContext) GetJWT() string
func (*HTTPContext) GetMessage ¶ added in v1.2.0
func (c *HTTPContext) GetMessage() string
func (*HTTPContext) GetPageOptions ¶ added in v1.2.0
func (c *HTTPContext) GetPageOptions() *models.PageOptions
func (*HTTPContext) GetPageOptionsWithOptions ¶ added in v1.2.0
func (c *HTTPContext) GetPageOptionsWithOptions(options *PageOptionsOptions) *models.PageOptions
func (*HTTPContext) GetSignature ¶ added in v1.2.0
func (c *HTTPContext) GetSignature() string
func (HTTPContext) GetUserAgent ¶ added in v1.2.0
func (c HTTPContext) GetUserAgent() *user_agent.UserAgent
func (*HTTPContext) Log ¶ added in v1.2.0
func (c *HTTPContext) Log() ILogger
func (*HTTPContext) NewError ¶ added in v1.2.0
func (c *HTTPContext) NewError(err error, errorType IError, args ...interface{}) IError
func (*HTTPContext) WithSaveCache ¶ added in v1.2.0
func (c *HTTPContext) WithSaveCache(data interface{}, key string, duration time.Duration) interface{}
type HTTPContextOptions ¶ added in v1.2.0
type HTTPContextOptions struct {
RateLimit *middleware.RateLimiterMemoryStoreConfig
AllowOrigins []string
AllowHeaders []string
ContextOptions *ContextOptions
}
type HandlerFunc ¶ added in v1.2.0
type HandlerFunc func(IHTTPContext) error
type IArchiver ¶ added in v1.2.0
type IArchiver interface {
FromURLs(fileName string, urls []string, options *ArchiverOptions) ([]byte, IError)
FromBytes(fileName string, body []ArchiveByteBody, options *ArchiverOptions) ([]byte, IError)
}
func NewArchiver ¶ added in v1.2.0
type ICSV ¶ added in v1.2.0
type ICSV[T any] interface { //Reader ReadFromFile(data []byte, options *ICSVOptions) ([]T, error) ReadFromPath(path string, options *ICSVOptions) ([]T, error) ReadFromString(data string, options *ICSVOptions) ([]T, error) ReadFromURL(url string, options *ICSVOptions) ([]T, error) ReadFromFileMaps(data []byte, options *ICSVOptions) ([]map[string]interface{}, error) }
type ICSVOptions ¶ added in v1.2.0
type IContext ¶ added in v1.2.0
type IContext interface {
MQ() IMQ
DB() *gorm.DB
DBS(name string) *gorm.DB
DBMongo() IMongoDB
DBSMongo(name string) IMongoDB
ENV() IENV
Log() ILogger
Type() consts.ContextType
NewError(err error, errorType IError, args ...interface{}) IError
Requester() IRequester
Cache() ICache
Caches(name string) ICache
GetData(name string) interface{}
GetAllData() map[string]interface{}
SetData(name string, data interface{})
SetUser(user *ContextUser)
GetUser() *ContextUser
}
func NewContext ¶ added in v1.2.0
func NewContext(options *ContextOptions) IContext
type ICronjobContext ¶ added in v1.2.0
type ICronjobContext interface {
IContext
Job() *gocron.Scheduler
Start()
AddJob(job *gocron.Scheduler, handlerFunc func(ctx ICronjobContext) error)
}
func NewCronjobContext ¶ added in v1.2.0
func NewCronjobContext(options *CronjobContextOptions) ICronjobContext
type IENV ¶ added in v1.1.0
type IENV interface {
Config() *ENVConfig
IsDev() bool
IsTest() bool
IsMock() bool
IsProd() bool
Bool(key string) bool
Int(key string) int
String(key string) string
All() map[string]string
}
func NewENVPath ¶ added in v1.1.0
type IEmail ¶ added in v1.2.0
type IEmail interface {
SendHTML(from string, to []string, subject string, body string) IError
SendHTMLWithAttach(from string, to []string, subject string, body string, file []byte, fileName string) IError
SendText(from string, to []string, subject string, body string) IError
ParseHTMLToString(path string, data interface{}) (string, IError)
}
type IError ¶ added in v1.2.0
type IError interface {
Error() string
GetCode() string
GetStatus() int
JSON() interface{}
OriginalError() error
GetMessage() interface{}
}
func DBErrorToIError ¶ added in v1.2.0
func NewValidatorFields ¶ added in v1.2.0
func NewValidatorFields(fields interface{}) IError
func RequesterToStruct ¶ added in v1.2.0
func RequesterToStruct(desc interface{}, requester func() (*RequestResponse, error)) IError
func RequesterToStructPagination ¶ added in v1.2.0
func RequesterToStructPagination(items interface{}, options *models.PageOptions, requester func() (*RequestResponse, error)) (*models.PageResponse, IError)
type IFMC ¶ added in v1.3.0
type IFMC interface {
SendSimpleMessage(tokens []string, payload *IFMCMessage) IError
SendSimpleMessages(payload []IFMCPayload) IError
SendTopic(topic string, payload map[string]string) IError
}
type IFMCMessage ¶ added in v1.3.5
type IFMCPayload ¶ added in v1.3.5
type IFMCPayload struct {
Token string `json:"token"`
Message *IFMCMessage `json:"payload"`
}
type IHTTPContext ¶ added in v1.2.0
type IHTTPContext interface {
IContext
echo.Context
BindWithValidate(ctx IValidateContext) IError
BindWithValidateMessage(ctx IValidateContext) IError
BindWithValidateJWT(ctx IValidateContext) IError
BindOnly(i interface{}) IError
GetSignature() string
GetMessage() string
GetPageOptions() *models.PageOptions
GetPageOptionsWithOptions(options *PageOptionsOptions) *models.PageOptions
GetUserAgent() *user_agent.UserAgent
WithSaveCache(data interface{}, key string, duration time.Duration) interface{}
}
func NewHTTPContext ¶ added in v1.2.0
func NewHTTPContext(ctx echo.Context, options *HTTPContextOptions) IHTTPContext
type IMQ ¶ added in v1.2.0
type IMQ interface {
Close()
PublishJSON(name string, data interface{}, options *MQPublishOptions) error
Consume(ctx IMQContext, name string, onConsume func(message amqp.Delivery), options *MQConsumeOptions)
Conn() *amqp.Connection
ReConnect()
}
type IMQContext ¶ added in v1.2.0
type IMQContext interface {
IContext
AddConsumer(handlerFunc func(ctx IMQContext))
Consume(name string, onConsume func(message amqp.Delivery), options *MQConsumeOptions)
Start()
}
func NewMQContext ¶ added in v1.2.0
func NewMQContext(options *MQContextOptions) IMQContext
func NewMQServer ¶ added in v1.2.0
func NewMQServer(options *MQContextOptions) IMQContext
type IMongoDB ¶ added in v1.2.0
type IMongoDB interface {
DB() *mongo.Database
Create(coll string, document interface{}, opts ...*options.InsertOneOptions) (*mongo.InsertOneResult, error)
FindAggregate(dest interface{}, coll string, pipeline interface{}, opts ...*options.AggregateOptions) error
FindAggregatePagination(dest interface{}, coll string, pipeline interface{}, pageOptions *models.PageOptions, opts ...*options.AggregateOptions) (*models.PageResponse, error)
FindAggregateOne(dest interface{}, coll string, pipeline interface{}, opts ...*options.AggregateOptions) error
Find(dest interface{}, coll string, filter interface{}, opts ...*options.FindOptions) error
FindPagination(dest interface{}, coll string, filter interface{}, pageOptions *models.PageOptions, opts ...*options.FindOptions) (*models.PageResponse, error)
FindOne(dest interface{}, coll string, filter interface{}, opts ...*options.FindOneOptions) error
FindOneAndUpdate(dest interface{}, coll string, filter interface{}, update interface{}, opts ...*options.FindOneAndUpdateOptions) error
UpdateOne(coll string, filter interface{}, update interface{}, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)
Count(coll string, filter interface{}, opts ...*options.CountOptions) (int64, error)
Drop(coll string) error
DeleteOne(coll string, filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)
DeleteMany(coll string, filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)
FindOneAndDelete(coll string, filter interface{}, opts ...*options.FindOneAndDeleteOptions) error
Close()
Helper() IMongoDBHelper
CreateIndex(coll string, models []mongo.IndexModel, opts ...*options.CreateIndexesOptions) ([]string, error)
DropIndex(coll string, name string, opts ...*options.DropIndexesOptions) (*MongoDropIndexResult, error)
DropAll(coll string, opts ...*options.DropIndexesOptions) (*MongoDropIndexResult, error)
ListIndex(coll string, opts ...*options.ListIndexesOptions) ([]MongoListIndexResult, error)
}
type IMongoDBHelper ¶ added in v1.2.0
type IMongoDBHelper interface {
Lookup(options *MongoLookupOptions) bson.M
Set(options bson.M) bson.M
Project(options bson.M) bson.M
Size(expression string) bson.M
Filter(options *MongoFilterOptions) bson.M
Match(options bson.M) bson.M
Unwind(field string) bson.M
ReplaceRoot(options interface{}) bson.M
Or(options []bson.M) bson.M
}
func NewMongoHelper ¶ added in v1.2.0
func NewMongoHelper() IMongoDBHelper
type IMongoIndexBatch ¶ added in v1.2.0
type IMongoIndexer ¶ added in v1.2.0
type IMongoIndexer interface {
Add(batch IMongoIndexBatch)
Execute() error
}
func NewMongoIndexer ¶ added in v1.2.0
func NewMongoIndexer(ctx IContext) IMongoIndexer
type IRequester ¶ added in v1.2.0
type IRequester interface {
Get(url string, options *RequesterOptions) (*RequestResponse, error)
Delete(url string, options *RequesterOptions) (*RequestResponse, error)
Post(url string, body interface{}, options *RequesterOptions) (*RequestResponse, error)
Create(method consts.RequesterMethodType, url string, body interface{}, options *RequesterOptions) (*RequestResponse, error)
Put(url string, body interface{}, options *RequesterOptions) (*RequestResponse, error)
Patch(url string, body interface{}, options *RequesterOptions) (*RequestResponse, error)
}
func NewRequester ¶ added in v1.2.0
func NewRequester(ctx IContext) IRequester
type IS3 ¶ added in v1.1.0
type IS3 interface {
GetObject(path string, opts *ss3.GetObjectInput) (*ss3.GetObjectOutput, error)
PutObject(objectName string, file io.ReadSeeker, opts *ss3.PutObjectInput, uploadOptions *UploadOptions) (*ss3.PutObjectOutput, error)
PutObjectByURL(objectName string, url string, opts *ss3.PutObjectInput, uploadOptions *UploadOptions) (*ss3.PutObjectOutput, error)
}
type IValidMessage ¶ added in v1.2.0
type IValidMessage struct {
Name string `json:"-"`
Code string `json:"code"`
Message string `json:"message"`
Data interface{} `json:"data,omitempty"`
}
func (IValidMessage) Error ¶ added in v1.2.0
func (f IValidMessage) Error() string
type IValidateContext ¶ added in v1.2.0
type KeywordCondition ¶ added in v1.2.0
type KeywordCondition string
type KeywordConditionWrapper ¶ added in v1.2.0
type KeywordConditionWrapper struct {
Condition KeywordCondition
KeywordOptions []KeywordOptions
}
func NewKeywordAndCondition ¶ added in v1.2.0
func NewKeywordAndCondition(keywordOptions []KeywordOptions) *KeywordConditionWrapper
func NewKeywordOrCondition ¶ added in v1.2.0
func NewKeywordOrCondition(keywordOptions []KeywordOptions) *KeywordConditionWrapper
type KeywordOptions ¶ added in v1.2.0
type KeywordOptions struct {
Type KeywordType
Key string
Value string
}
func NewKeywordMustMatchOption ¶ added in v1.2.0
func NewKeywordMustMatchOption(key string, value string) *KeywordOptions
func NewKeywordMustMatchOptions ¶ added in v1.2.0
func NewKeywordMustMatchOptions(keys []string, value string) []KeywordOptions
func NewKeywordWildCardOption ¶ added in v1.2.0
func NewKeywordWildCardOption(key string, value string) *KeywordOptions
func NewKeywordWildCardOptions ¶ added in v1.2.0
func NewKeywordWildCardOptions(keys []string, value string) []KeywordOptions
type KeywordType ¶ added in v1.2.0
type KeywordType string
type Logger ¶ added in v1.2.0
type Logger struct {
RequestID string
HostName string
Type consts.ContextType
// contains filtered or unexported fields
}
Log is the logger utility with information of request context
func NewLoggerSimple ¶ added in v1.2.0
func NewLoggerSimple() *Logger
NewLoggerSimple return plain text simple logger
func (*Logger) Debug ¶ added in v1.2.0
func (logger *Logger) Debug(args ...interface{})
Debug log debug level
func (*Logger) DebugWithSkip ¶ added in v1.2.0
func (*Logger) ErrorWithSkip ¶ added in v1.2.0
Error log error level
type MQConsumeOptions ¶ added in v1.2.0
type MQContext ¶ added in v1.2.0
type MQContext struct {
IContext
}
func (*MQContext) AddConsumer ¶ added in v1.2.0
func (c *MQContext) AddConsumer(handlerFunc func(ctx IMQContext))
type MQContextOptions ¶ added in v1.2.0
type MQContextOptions struct {
ContextOptions *ContextOptions
}
type MQPublishOptions ¶ added in v1.2.0
type MongoDB ¶ added in v1.2.0
type MongoDB struct {
// contains filtered or unexported fields
}
func (MongoDB) Create ¶ added in v1.2.0
func (m MongoDB) Create(coll string, document interface{}, opts ...*options.InsertOneOptions) (*mongo.InsertOneResult, error)
func (MongoDB) CreateIndex ¶ added in v1.2.0
func (m MongoDB) CreateIndex(coll string, models []mongo.IndexModel, opts ...*options.CreateIndexesOptions) ([]string, error)
func (MongoDB) DeleteMany ¶ added in v1.2.0
func (m MongoDB) DeleteMany(coll string, filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)
func (MongoDB) DeleteOne ¶ added in v1.2.0
func (m MongoDB) DeleteOne(coll string, filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)
func (MongoDB) DropAll ¶ added in v1.2.0
func (m MongoDB) DropAll(coll string, opts ...*options.DropIndexesOptions) (*MongoDropIndexResult, error)
func (MongoDB) DropIndex ¶ added in v1.2.0
func (m MongoDB) DropIndex(coll string, name string, opts ...*options.DropIndexesOptions) (*MongoDropIndexResult, error)
func (MongoDB) Find ¶ added in v1.2.0
func (m MongoDB) Find(dest interface{}, coll string, filter interface{}, opts ...*options.FindOptions) error
func (MongoDB) FindAggregate ¶ added in v1.2.0
func (m MongoDB) FindAggregate(dest interface{}, coll string, pipeline interface{}, opts ...*options.AggregateOptions) error
func (MongoDB) FindAggregateOne ¶ added in v1.2.0
func (m MongoDB) FindAggregateOne(dest interface{}, coll string, pipeline interface{}, opts ...*options.AggregateOptions) error
func (MongoDB) FindAggregatePagination ¶ added in v1.2.0
func (m MongoDB) FindAggregatePagination(dest interface{}, coll string, pipeline interface{}, pageOptions *models.PageOptions, opts ...*options.AggregateOptions) (*models.PageResponse, error)
func (MongoDB) FindOne ¶ added in v1.2.0
func (m MongoDB) FindOne(dest interface{}, coll string, filter interface{}, opts ...*options.FindOneOptions) error
func (MongoDB) FindOneAndDelete ¶ added in v1.2.0
func (m MongoDB) FindOneAndDelete(coll string, filter interface{}, opts ...*options.FindOneAndDeleteOptions) error
func (MongoDB) FindOneAndUpdate ¶ added in v1.2.0
func (m MongoDB) FindOneAndUpdate(dest interface{}, coll string, filter interface{}, update interface{}, opts ...*options.FindOneAndUpdateOptions) error
func (MongoDB) FindPagination ¶ added in v1.2.0
func (m MongoDB) FindPagination(dest interface{}, coll string, filter interface{}, pageOptions *models.PageOptions, opts ...*options.FindOptions) (*models.PageResponse, error)
func (MongoDB) Helper ¶ added in v1.2.0
func (m MongoDB) Helper() IMongoDBHelper
func (MongoDB) ListIndex ¶ added in v1.2.0
func (m MongoDB) ListIndex(coll string, opts ...*options.ListIndexesOptions) ([]MongoListIndexResult, error)
func (MongoDB) UpdateOne ¶ added in v1.2.0
func (m MongoDB) UpdateOne(coll string, filter interface{}, update interface{}, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)
type MongoDropIndexResult ¶ added in v1.2.0
type MongoDropIndexResult struct {
DropCount int64 `json:"drop_count" bson:"nIndexesWas"`
}
type MongoFilterOptions ¶ added in v1.2.0
type MongoIndexer ¶ added in v1.2.0
type MongoIndexer struct {
Batches []IMongoIndexBatch
// contains filtered or unexported fields
}
func (*MongoIndexer) Add ¶ added in v1.2.0
func (i *MongoIndexer) Add(batch IMongoIndexBatch)
func (*MongoIndexer) Execute ¶ added in v1.2.0
func (i *MongoIndexer) Execute() error
type MongoListIndexResult ¶ added in v1.2.0
type MongoLookupOptions ¶ added in v1.2.0
type PageOptionsOptions ¶ added in v1.2.0
type PageOptionsOptions struct {
OrderByAllowed []string
}
type RequestResponse ¶ added in v1.2.0
type RequestResponse struct {
Data map[string]interface{}
RawData []byte
ErrorCode string
StatusCode int
Header http.Header
ContentLength int64
TransferEncoding []string
Uncompressed bool
Trailer http.Header
Request *http.Request
TLS *tls.ConnectionState
}
func RequestWrapper
deprecated
added in
v1.2.0
func RequestWrapper(dest interface{}, requester func() (*RequestResponse, error)) (*RequestResponse, error)
Deprecated: RequestWrapper is deprecated, use RequestToStruct or RequestToStructPagination instead.
type Requester ¶ added in v1.2.0
type Requester struct {
// contains filtered or unexported fields
}
func (Requester) Create ¶ added in v1.2.0
func (r Requester) Create(method consts.RequesterMethodType, url string, body interface{}, options *RequesterOptions) (*RequestResponse, error)
func (Requester) Delete ¶ added in v1.2.0
func (r Requester) Delete(url string, options *RequesterOptions) (*RequestResponse, error)
func (Requester) Get ¶ added in v1.2.0
func (r Requester) Get(url string, options *RequesterOptions) (*RequestResponse, error)
func (Requester) Patch ¶ added in v1.2.0
func (r Requester) Patch(url string, body interface{}, options *RequesterOptions) (*RequestResponse, error)
func (Requester) Post ¶ added in v1.2.0
func (r Requester) Post(url string, body interface{}, options *RequesterOptions) (*RequestResponse, error)
func (Requester) Put ¶ added in v1.2.0
func (r Requester) Put(url string, body interface{}, options *RequesterOptions) (*RequestResponse, error)
type RequesterOptions ¶ added in v1.2.0
type S3Config ¶ added in v1.1.0
type UploadOptions ¶ added in v1.1.0
type Valid ¶ added in v1.2.0
type Valid struct {
// contains filtered or unexported fields
}
Validator type
func (*Valid) GetMessage ¶ added in v1.2.0
func (v *Valid) GetMessage() interface{}
func (*Valid) Must ¶ added in v1.2.0
func (v *Valid) Must(x bool, msg *IValidMessage) bool
Must checks x must not an error or true if bool and return true if valid
msg must be error or string
func (*Valid) OriginalError ¶ added in v1.2.0
func (*Valid) OriginalErrorMessage ¶ added in v1.2.0
type ValidError ¶ added in v1.2.0
type ValidError struct {
// contains filtered or unexported fields
}
Error is the validate error
func (*ValidError) Error ¶ added in v1.2.0
func (err *ValidError) Error() string
Error implements error interface
func (*ValidError) Errors ¶ added in v1.2.0
func (err *ValidError) Errors() []error
Errors returns errors
func (*ValidError) Strings ¶ added in v1.2.0
func (err *ValidError) Strings() []string
Strings returns errors in strings
Source Files
¶
- archiver.go
- cache.go
- context.go
- cronjob_context.go
- csv.go
- database.go
- database_mongo.go
- database_mongo_helper.go
- database_mongo_indexer.go
- email.go
- entry.go
- env.go
- error.go
- error_mock.go
- faker.go
- fcm.go
- http_context.go
- http_middleware_core.go
- http_middleware_cors.go
- http_middleware_error.go
- http_middleware_logger.go
- http_middleware_rate_limit.go
- http_middleware_request_id.go
- http_middleware_with_cache.go
- http_server.go
- logger.go
- mq.go
- mq_context.go
- mq_server.go
- requester.go
- s3.go
- seeder.go
- sentry.go
- valid.go
- valid_base_validator.go
- valid_message.go
- validator.go
Click to show internal directories.
Click to hide internal directories.