...

Package core

import "gitlab.finema.co/finema/idin-core"
Overview
Index
Subdirectories

Overview ▾

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 HTTPMiddlewareCore(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 MockMiddleware(model interface{}, options *MockMiddlewareOptions) func(next echo.HandlerFunc) echo.HandlerFunc
func NewHTTPServer(options *HTTPContextOptions) *echo.Echo
func NewMockENV() *mockENV
func Recover(textError string)
func RequesterToStructPagination(items interface{}, options *PageOptions, requester func() (*RequestResponse, error)) (*PageResponse, IError)
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 ABCIContext
    func (A ABCIContext) GetMessageJSON(tx []byte) string
    func (A ABCIContext) GetOperation(tx []byte) string
type ABCIContextOptions
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, fieldPath 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 ContextMock
    func NewMockContext() *ContextMock
    func (m *ContextMock) Cache() ICache
    func (m *ContextMock) Caches(name string) ICache
    func (m *ContextMock) DB() *gorm.DB
    func (m *ContextMock) DBMongo() IMongoDB
    func (m *ContextMock) DBS(name string) *gorm.DB
    func (m *ContextMock) DBSMongo(name string) IMongoDB
    func (m *ContextMock) ENV() IENV
    func (m *ContextMock) Log() ILogger
    func (m *ContextMock) MQ() IMQ
    func (m *ContextMock) NewError(err error, errorType IError, args ...interface{}) IError
    func (m *ContextMock) Requester() IRequester
    func (m *ContextMock) SetType(t consts.ContextType)
    func (m *ContextMock) Type() string
type ContextOptions
type ContextUser
type CronjobContext
    func (c CronjobContext) AddJob(job *gocron.Scheduler, handlerFunc func(ctx ICronjobContext) error)
    func (c CronjobContext) Job() *gocron.Scheduler
    func (c CronjobContext) Start()
type CronjobContextOptions
type Database
    func NewDatabase(env *ENVConfig) *Database
    func NewDatabaseWithConfig(env *ENVConfig, config *gorm.Config) *Database
    func (db *Database) Connect() (*gorm.DB, error)
type DatabaseCache
    func NewCache(env *ENVConfig) *DatabaseCache
    func (r DatabaseCache) Connect() (ICache, error)
type DatabaseMongo
    func NewDatabaseMongo(env *ENVConfig) *DatabaseMongo
    func (db *DatabaseMongo) Connect() (IMongoDB, error)
type E2EContext
type E2EContextOptions
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
    func (c Error) Error() string
    func (c Error) GetCode() string
    func (c Error) GetMessage() interface{}
    func (c Error) GetStatus() int
    func (c Error) JSON() interface{}
    func (c Error) OriginalError() error
type FieldError
    func (f FieldError) Error() string
    func (f FieldError) GetCode() string
    func (f FieldError) GetMessage() interface{}
    func (FieldError) GetStatus() int
    func (f FieldError) JSON() interface{}
    func (f FieldError) OriginalError() error
    func (f FieldError) OriginalErrorMessage() string
type File
    func (f File) Name() string
    func (f File) Value() []byte
type HTTPContext
    func (c *HTTPContext) BindOnly(i interface{}) IError
    func (c *HTTPContext) BindWithValidate(ctx IValidateContext) IError
    func (c *HTTPContext) BindWithValidateMessage(ctx IValidateContext) IError
    func (c *HTTPContext) GetMessage() string
    func (c *HTTPContext) GetPageOptions() *PageOptions
    func (c *HTTPContext) GetPageOptionsWithOptions(options *PageOptionsOptions) *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 IABCIContext
    func NewABCIContext(options *ABCIContextOptions) IABCIContext
type IArchiver
    func NewArchiver(ctx IContext) IArchiver
type ICSV
    func NewCSV[T any](ctx IContext) ICSV[T]
type ICSVOptions
type ICache
type IContext
    func NewContext(options *ContextOptions) IContext
type ICronjobContext
    func NewCronjobContext(options *CronjobContextOptions) ICronjobContext
type IE2EContext
    func NewE2EContext(options *E2EContextOptions) IE2EContext
type IENV
    func NewENVPath(path string) IENV
    func NewEnv() IENV
type IEmail
    func NewEmail(ctx IContext) 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
type IFile
    func NewFile(name string, value []byte) IFile
type IHTTPContext
    func NewHTTPContext(ctx echo.Context, options *HTTPContextOptions) IHTTPContext
type ILogger
type IMQ
type IMQContext
    func NewMQContext(options *MQContextOptions) IMQContext
    func NewMQServer(options *MQContextOptions) IMQContext
type IMongoDB
type IMongoDBHelper
    func NewMongoHelper() IMongoDBHelper
type IMongoIndexBatch
type IMongoIndexer
    func NewMongoIndexer(ctx IContext) IMongoIndexer
type IRequester
    func NewRequester(ctx IContext) IRequester
type IS3
type ISeed
type IValidMessage
    func (f IValidMessage) Error() string
type IValidate
type IValidateContext
type IWinRM
    func NewWinRM(ctx IContext) IWinRM
type KeywordCondition
type KeywordConditionWrapper
    func NewKeywordAndCondition(keywordOptions []KeywordOptions) *KeywordConditionWrapper
    func NewKeywordOrCondition(keywordOptions []KeywordOptions) *KeywordConditionWrapper
type KeywordOptions
    func NewKeywordMustMatchOption(key string, value string) *KeywordOptions
    func NewKeywordMustMatchOptions(keys []string, value string) []KeywordOptions
    func NewKeywordWildCardOption(key string, value string) *KeywordOptions
    func NewKeywordWildCardOptions(keys []string, value string) []KeywordOptions
type KeywordType
type Logger
    func NewLogger(ctx IContext) *Logger
    func NewLoggerSimple() *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
    func NewMQ(env *ENVConfig) *MQ
    func (m *MQ) Connect() (IMQ, error)
    func (m *MQ) ReConnect() (*amqp.Connection, error)
type MQConsumeOptions
type MQContext
    func (c *MQContext) AddConsumer(handlerFunc func(ctx IMQContext))
    func (c *MQContext) Consume(name string, onConsume func(message amqp.Delivery), options *MQConsumeOptions)
    func (c *MQContext) Start()
type MQContextOptions
type MQPublishOptions
type Map
type MockCache
    func NewMockCache() *MockCache
    func (m *MockCache) Close()
    func (m *MockCache) Del(key string) error
    func (m *MockCache) Get(dest interface{}, key string) error
    func (m *MockCache) GetJSON(dest interface{}, key string) error
    func (m *MockCache) Set(key string, value interface{}, expiration time.Duration) error
    func (m *MockCache) SetJSON(key string, value interface{}, expiration time.Duration) error
type MockDatabase
    func NewMockDatabase() *MockDatabase
type MockLogger
    func NewMockLogger() *MockLogger
    func (m *MockLogger) Debug(args ...interface{})
    func (m *MockLogger) Error(message error, args ...interface{})
    func (m *MockLogger) Info(args ...interface{})
    func (m *MockLogger) Warn(args ...interface{})
type MockMQ
    func NewMockMQ() *MockMQ
    func (m *MockMQ) Close()
    func (m *MockMQ) Conn() *amqp.Connection
    func (m *MockMQ) Consume(name string, onConsume func(message amqp.Delivery), options *MQConsumeOptions) error
    func (m *MockMQ) PublishJSON(name string, data interface{}, options *MQPublishOptions) error
type MockMiddlewareManual
type MockMiddlewareOptions
type MockMiddlewareWrapper
type MockMongoDB
    func NewMockMongoDB() *MockMongoDB
    func (m *MockMongoDB) Close()
    func (m *MockMongoDB) Count(coll string, filter interface{}, opts ...*options.CountOptions) (int64, error)
    func (m *MockMongoDB) Create(coll string, document interface{}, opts ...*options.InsertOneOptions) (*mongo.InsertOneResult, error)
    func (m *MockMongoDB) DB() *mongo.Database
    func (m *MockMongoDB) DeleteMany(coll string, filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)
    func (m *MockMongoDB) DeleteOne(coll string, filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)
    func (m *MockMongoDB) Drop(coll string) error
    func (m *MockMongoDB) Find(dest interface{}, coll string, filter interface{}, opts ...*options.FindOptions) error
    func (m *MockMongoDB) FindAggregate(dest interface{}, coll string, pipeline interface{}, opts ...*options.AggregateOptions) error
    func (m *MockMongoDB) FindAggregateOne(dest interface{}, coll string, pipeline interface{}, opts ...*options.AggregateOptions) error
    func (m *MockMongoDB) FindAggregatePagination(dest interface{}, coll string, pipeline interface{}, pageOptions *PageOptions, opts ...*options.AggregateOptions) (*PageResponse, error)
    func (m *MockMongoDB) FindOne(dest interface{}, coll string, filter interface{}, opts ...*options.FindOneOptions) error
    func (m *MockMongoDB) FindOneAndDelete(coll string, filter interface{}, opts ...*options.FindOneAndDeleteOptions) error
    func (m *MockMongoDB) FindOneAndUpdate(dest interface{}, coll string, filter interface{}, update interface{}, opts ...*options.FindOneAndUpdateOptions) error
    func (m *MockMongoDB) FindPagination(dest interface{}, coll string, filter interface{}, pageOptions *PageOptions, opts ...*options.FindOptions) (*PageResponse, error)
    func (m *MockMongoDB) Helper() IMongoDBHelper
    func (m *MockMongoDB) UpdateOne(coll string, filter interface{}, update interface{}, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)
type MockMongoIndexBatch
    func NewMockMongoIndexBatch() *MockMongoIndexBatch
    func (m *MockMongoIndexBatch) Name() string
    func (m *MockMongoIndexBatch) Run() error
type MockMongoIndexer
    func NewMockMongoIndexer() *MockMongoIndexer
    func (m *MockMongoIndexer) Add(batch *MockMongoIndexBatch)
    func (m *MockMongoIndexer) Execute() error
type MockRequester
    func NewMockRequester() *MockRequester
    func (m *MockRequester) Delete(url string, options *RequesterOptions) (*RequestResponse, error)
    func (m *MockRequester) Get(url string, options *RequesterOptions) (*RequestResponse, error)
    func (m *MockRequester) Patch(url string, body interface{}, options *RequesterOptions) (*RequestResponse, error)
    func (m *MockRequester) Post(url string, body interface{}, options *RequesterOptions) (*RequestResponse, error)
    func (m *MockRequester) Put(url string, body interface{}, options *RequesterOptions) (*RequestResponse, error)
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{}, opts ...*options.FindOptions) error
    func (m MongoDB) FindAggregate(dest interface{}, coll string, pipeline interface{}, opts ...*options.AggregateOptions) error
    func (m MongoDB) FindAggregateOne(dest interface{}, coll string, pipeline interface{}, opts ...*options.AggregateOptions) error
    func (m MongoDB) FindAggregatePagination(dest interface{}, coll string, pipeline interface{}, pageOptions *PageOptions, opts ...*options.AggregateOptions) (*PageResponse, error)
    func (m MongoDB) FindOne(dest interface{}, coll string, filter interface{}, opts ...*options.FindOneOptions) 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{}, opts ...*options.FindOneAndUpdateOptions) error
    func (m MongoDB) FindPagination(dest interface{}, coll string, filter interface{}, pageOptions *PageOptions, opts ...*options.FindOptions) (*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{}, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)
type MongoDropIndexResult
type MongoFilterOptions
type MongoIndexer
    func (i *MongoIndexer) Add(batch IMongoIndexBatch)
    func (i *MongoIndexer) Execute() error
type MongoListIndexResult
type MongoLookupOptions
type PageOptions
    func (p *PageOptions) SetOrderDefault(orders ...string)
type PageOptionsOptions
type PageResponse
    func Paginate(db *gorm.DB, model interface{}, options *PageOptions) (*PageResponse, error)
type Pagination
    func NewPagination(items interface{}, options *PageResponse) *Pagination
type RequestResponse
    func RequestWrapper(dest interface{}, requester func() (*RequestResponse, error)) (*RequestResponse, error)
type Requester
    func (r Requester) Create(method RequesterMethodType, url string, body interface{}, options *RequesterOptions) (*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 RequesterMethodType
type RequesterOptions
type S3Config
    func NewS3(env *ENVConfig) *S3Config
    func (r *S3Config) Connect() (IS3, error)
type Seeder
    func NewSeeder() *Seeder
    func (receiver Seeder) Add(seeder ISeed) error
type UploadOptions
type Valid
    func NewValid() *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
    func (err *ValidError) Error() string
    func (err *ValidError) Errors() []error
    func (err *ValidError) Strings() []string
type Validator
    func (cv *Validator) Validate(i interface{}) error
type WinRM
    func (w *WinRM) Command(command string, isProduction bool) (*WinRMResult, IError)
type WinRMResult

Package files

abci_context.go archiver.go cache.go cache_mock.go context.go context_mock.go cronjob_context.go csv.go database.go database_mock.go database_mongo.go database_mongo_helper.go database_mongo_indexer.go database_mongo_indexer_mock.go database_mongo_mock.go e2e_context.go email.go env.go env_mock.go error.go error_mock.go faker.go http_context.go http_middleware_core.go http_middleware_cors.go http_middleware_error.go http_middleware_logger.go http_middleware_mock.go http_middleware_rate_limit.go http_middleware_request_id.go http_middleware_with_cache.go http_server.go logger.go logger_mock.go mq.go mq_context.go mq_mock.go mq_server.go pagination.model.go request.const.go requester.go requester_mock.go s3.go seeder.go sentry.go types.go valid.go valid_base_validator.go valid_message.go validator.go winrm.go

Constants

const (
    MustMatch KeywordType = "must_match"
    Wildcard  KeywordType = "wildcard"

    And KeywordCondition = "and"
    Or  KeywordCondition = "or"
)
const (
    DatabaseDriverPOSTGRES = "postgres"
    DatabaseDriverMSSQL    = "mssql"
    DatabaseDriverMYSQL    = "mysql"
)
const DateFormat = "2006-01-02 15:04:05"
const EnvFileName = ".env"
const EnvTestFileName = "test.env"
const TimeFormat = "15:04:05"
const TimeFormatRegex = "^([01]?[0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]$"

Variables

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,
        },
    }
}
var ArrayM = func(field string) *IValidMessage {
    return &IValidMessage{
        Name:    field,
        Code:    "INVALID_ARRAY",
        Message: "The " + field + " field must be array format",
    }
}
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,
    }
}
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,
    }
}
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,
    }
}
var Base64M = func(field string) *IValidMessage {
    return &IValidMessage{
        Name:    field,
        Code:    "BASE64",
        Message: "The " + field + " must be base64 format",
    }
}
var BooleanM = func(field string) *IValidMessage {
    return &IValidMessage{
        Name:    field,
        Code:    "INVALID_TYPE",
        Message: "The " + field + " field must be boolean",
    }
}
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),
    }
}
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),
    }
}
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`,
    }
}
var EmailM = func(field string) *IValidMessage {
    return &IValidMessage{
        Name:    field,
        Code:    "INVALID_EMAIL",
        Message: fmt.Sprintf("The %v field must be Email Address", field),
    }
}
var EmailServiceParserError = Error{
    Status:  http.StatusInternalServerError,
    Code:    "EMAIL_PARSING_ERROR",
    Message: "can not parse email",
}
var EmailServiceSendFailed = Error{
    Status:  http.StatusBadGateway,
    Code:    "SEND_EMAIL_ERROR",
    Message: "can not send email",
}
var ExistsM = func(field string) *IValidMessage {
    return &IValidMessage{
        Name:    field,
        Code:    "NOT_EXISTS",
        Message: "The " + field + " field's value is not exists",
    }
}
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),
    }
}
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,
    }
}
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,
    }
}
var IPM = func(field string) *IValidMessage {
    return &IValidMessage{
        Name:    field,
        Code:    "INVALID_IP",
        Message: fmt.Sprintf("The %v field must be IP Address", field),
    }
}
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,
    }
}
var JSONArrayM = func(field string) *IValidMessage {
    return &IValidMessage{
        Name:    field,
        Code:    "INVALID_JSON_ARRAY",
        Message: "The " + field + " field must be array format",
    }
}
var JSONM = func(field string) *IValidMessage {
    return &IValidMessage{
        Name:    field,
        Code:    "INVALID_JSON",
        Message: "The " + field + " field must be json",
    }
}
var JSONObjectEmptyM = func(field string) *IValidMessage {
    return &IValidMessage{
        Name:    field,
        Code:    "INVALID_JSON",
        Message: "The " + field + " field cannot be empty object",
    }
}
var JSONObjectM = func(field string) *IValidMessage {
    return &IValidMessage{
        Name:    field,
        Code:    "INVALID_JSON",
        Message: "The " + field + " field must be json object",
    }
}
var MQError = Error{
    Status:  http.StatusInternalServerError,
    Code:    "MQ_ERROR",
    Message: "mq internal error"}
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),
    }
}
var NumberM = func(field string) *IValidMessage {
    return &IValidMessage{
        Name:    field,
        Code:    "INVALID_TYPE",
        Message: "The " + field + " field cannot parse to number",
    }
}
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,
    }
}
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,
    }
}
var ObjectEmptyM = func(field string) *IValidMessage {
    return &IValidMessage{
        Name:    field,
        Code:    "INVALID_TYPE",
        Message: "The " + field + " field cannot be empty object",
    }
}
var RequiredM = func(field string) *IValidMessage {
    return &IValidMessage{
        Name:    field,
        Code:    "REQUIRED",
        Message: "The " + field + " field is required",
    }
}
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,
    }
}
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,
    }
}
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,
    }
}
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,
    }
}
var StringLowercaseM = func(field string) *IValidMessage {
    return &IValidMessage{
        Name:    field,
        Code:    "INVALID_STRING_LOWERCASE",
        Message: fmt.Sprintf("The %v field must be lowercase", field),
    }
}
var StringM = func(field string) *IValidMessage {
    return &IValidMessage{
        Name:    field,
        Code:    "INVALID_TYPE",
        Message: "The " + field + " field must be string",
    }
}
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,
    }
}
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,
    }
}
var StringUppercaseM = func(field string) *IValidMessage {
    return &IValidMessage{
        Name:    field,
        Code:    "INVALID_STRING_UPPERCASE",
        Message: fmt.Sprintf("The %v field must be uppercase", field),
    }
}
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),
    }
}
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),
    }
}
var TimeM = func(field string) *IValidMessage {
    return &IValidMessage{
        Name:    field,
        Code:    "INVALID_TIME",
        Message: "The " + field + ` field must be in "HH:mm:ss"" format`,
    }
}
var URLM = func(field string) *IValidMessage {
    return &IValidMessage{
        Name:    field,
        Code:    "INVALID_URL",
        Message: "The " + field + " field is not url",
    }
}
var UniqueM = func(field string) *IValidMessage {
    return &IValidMessage{
        Name:    field,
        Code:    "UNIQUE",
        Message: "The " + field + " field's value already exists",
    }
}

func CaptureError

func CaptureError(ctx IContext, level sentry.Level, err error, args ...interface{})

func CaptureErrorEcho

func CaptureErrorEcho(ctx echo.Context, level sentry.Level, err error)

func CaptureHTTPError

func CaptureHTTPError(ctx IHTTPContext, level sentry.Level, err error, args ...interface{})

func CaptureSimpleError

func CaptureSimpleError(level sentry.Level, err error, args ...interface{})

func Core

func Core(options *HTTPContextOptions) func(next echo.HandlerFunc) echo.HandlerFunc

func Crash

func Crash(err error) error

func ErrorToJson

func ErrorToJson(err error) (m map[string]jsonErr)

func Fake

func Fake(a interface{}) error

func GetBodyString

func GetBodyString(c echo.Context) []byte

func HTTPMiddlewareCore

func HTTPMiddlewareCore(options *HTTPContextOptions) echo.MiddlewareFunc

func HTTPMiddlewareCreateLogger

func HTTPMiddlewareCreateLogger(next echo.HandlerFunc) echo.HandlerFunc

func HTTPMiddlewareFromCache

func HTTPMiddlewareFromCache(key func(IHTTPContext) string) echo.MiddlewareFunc

func HTTPMiddlewareHandleError

func HTTPMiddlewareHandleError(env IENV) echo.HTTPErrorHandler

func HTTPMiddlewareHandleNotFound

func HTTPMiddlewareHandleNotFound(c echo.Context) error

func HTTPMiddlewareRateLimit

func HTTPMiddlewareRateLimit(options *HTTPContextOptions) echo.MiddlewareFunc

func HTTPMiddlewareRecoverWithConfig

func HTTPMiddlewareRecoverWithConfig(env IENV, config middleware.RecoverConfig) echo.MiddlewareFunc

func HTTPMiddlewareRequestID

func HTTPMiddlewareRequestID() echo.MiddlewareFunc

func IsError

func IsError(err error) bool

IsError returns true if given error is validate error

func MockMiddleware

func MockMiddleware(model interface{}, options *MockMiddlewareOptions) func(next echo.HandlerFunc) echo.HandlerFunc

func NewHTTPServer

func NewHTTPServer(options *HTTPContextOptions) *echo.Echo

func NewMockENV

func NewMockENV() *mockENV

func Recover

func Recover(textError string)

func RequesterToStructPagination

func RequesterToStructPagination(items interface{}, options *PageOptions, requester func() (*RequestResponse, error)) (*PageResponse, IError)

func SetSearch

func SetSearch(db *gorm.DB, keywordCondition *KeywordConditionWrapper) *gorm.DB

func SetSearchSimple

func SetSearchSimple(db *gorm.DB, q string, columns []string) *gorm.DB

func StartHTTPServer

func StartHTTPServer(e *echo.Echo, env IENV)

func WithHTTPContext

func WithHTTPContext(h HandlerFunc) echo.HandlerFunc

type ABCIContext

type ABCIContext struct {
    IContext
}

func (ABCIContext) GetMessageJSON

func (A ABCIContext) GetMessageJSON(tx []byte) string

func (ABCIContext) GetOperation

func (A ABCIContext) GetOperation(tx []byte) string

type ABCIContextOptions

type ABCIContextOptions struct {
    ContextOptions *ContextOptions
}

type ArchiveByteBody

type ArchiveByteBody struct {
    File []byte
    Name string
}

type ArchiverOptions

type ArchiverOptions struct {
}

type BaseValidator

type BaseValidator struct {
    // contains filtered or unexported fields
}

func (*BaseValidator) AddValidator

func (b *BaseValidator) AddValidator(errs ...*Valid)

func (*BaseValidator) Error

func (b *BaseValidator) Error() IError

func (*BaseValidator) GetValidator

func (b *BaseValidator) GetValidator() *Valid

func (*BaseValidator) IsArrayBetween

func (b *BaseValidator) IsArrayBetween(array interface{}, min int, max int, fieldPath string) (bool, *IValidMessage)

func (*BaseValidator) IsArrayMax

func (b *BaseValidator) IsArrayMax(array interface{}, size int, fieldPath string) (bool, *IValidMessage)

func (*BaseValidator) IsArrayMin

func (b *BaseValidator) IsArrayMin(array interface{}, size int, fieldPath string) (bool, *IValidMessage)

func (*BaseValidator) IsArraySize

func (b *BaseValidator) IsArraySize(array interface{}, size int, fieldPath string) (bool, *IValidMessage)

func (*BaseValidator) IsBase64

func (b *BaseValidator) IsBase64(field *string, fieldPath string) (bool, *IValidMessage)

func (*BaseValidator) IsBoolRequired

func (b *BaseValidator) IsBoolRequired(value interface{}, fieldPath string) (bool, *IValidMessage)

func (*BaseValidator) IsCustom

func (b *BaseValidator) IsCustom(customFunc func() (bool, *IValidMessage)) (bool, *IValidMessage)

func (*BaseValidator) IsDateTime

func (b *BaseValidator) IsDateTime(input *string, fieldPath string) (bool, *IValidMessage)

func (*BaseValidator) IsDateTimeAfter

func (b *BaseValidator) IsDateTimeAfter(input *string, after *string, fieldPath string) (bool, *IValidMessage)

func (*BaseValidator) IsDateTimeBefore

func (b *BaseValidator) IsDateTimeBefore(input *string, before *string, fieldPath string) (bool, *IValidMessage)

func (*BaseValidator) IsEmail

func (b *BaseValidator) IsEmail(field *string, fieldPath string) (bool, *IValidMessage)

func (*BaseValidator) IsExists

func (b *BaseValidator) IsExists(ctx IContext, field *string, table string, column string, fieldPath string) (bool, *IValidMessage)

func (*BaseValidator) IsExistsWithCondition

func (b *BaseValidator) IsExistsWithCondition(
    ctx IContext,
    table string,
    condition map[string]interface{},
    fieldPath string,
) (bool, *IValidMessage)

func (*BaseValidator) IsFloatNumberBetween

func (b *BaseValidator) IsFloatNumberBetween(field *float64, min float64, max float64, fieldPath string) (bool, *IValidMessage)

func (*BaseValidator) IsFloatNumberMax

func (b *BaseValidator) IsFloatNumberMax(field *float64, max float64, fieldPath string) (bool, *IValidMessage)

func (*BaseValidator) IsFloatNumberMin

func (b *BaseValidator) IsFloatNumberMin(field *float64, min float64, fieldPath string) (bool, *IValidMessage)

func (*BaseValidator) IsIP

func (b *BaseValidator) IsIP(field *string, fieldPath string) (bool, *IValidMessage)

func (*BaseValidator) IsJSONArray

func (b *BaseValidator) IsJSONArray(field *json.RawMessage, fieldPath string) (bool, *IValidMessage)

func (*BaseValidator) IsJSONArrayMax

func (b *BaseValidator) IsJSONArrayMax(field *json.RawMessage, max int, fieldPath string) (bool, *IValidMessage)

func (*BaseValidator) IsJSONArrayMin

func (b *BaseValidator) IsJSONArrayMin(field *json.RawMessage, min int, fieldPath string) (bool, *IValidMessage)

func (*BaseValidator) IsJSONBoolPathRequired

func (b *BaseValidator) IsJSONBoolPathRequired(json *json.RawMessage, path string, fieldPath string) (bool, *IValidMessage)

func (*BaseValidator) IsJSONObject

func (b *BaseValidator) IsJSONObject(field *json.RawMessage, fieldPath string) (bool, *IValidMessage)

func (*BaseValidator) IsJSONObjectNotEmpty

func (b *BaseValidator) IsJSONObjectNotEmpty(field *json.RawMessage, fieldPath string) (bool, *IValidMessage)

func (*BaseValidator) IsJSONObjectPath

func (b *BaseValidator) IsJSONObjectPath(j *json.RawMessage, path string, fieldPath string) (bool, *IValidMessage)

func (*BaseValidator) IsJSONPathRequireNotEmpty

func (b *BaseValidator) IsJSONPathRequireNotEmpty(j *json.RawMessage, path string, fieldPath string) (bool, *IValidMessage)

func (*BaseValidator) IsJSONPathRequired

func (b *BaseValidator) IsJSONPathRequired(j *json.RawMessage, path string, fieldPath string) (bool, *IValidMessage)

func (*BaseValidator) IsJSONPathStrIn

func (b *BaseValidator) IsJSONPathStrIn(json *json.RawMessage, path string, rules string, fieldPath string) (bool, *IValidMessage)

func (*BaseValidator) IsJSONRequired

func (b *BaseValidator) IsJSONRequired(field *json.RawMessage, fieldPath string) (bool, *IValidMessage)

func (*BaseValidator) IsJSONStrPathRequired

func (b *BaseValidator) IsJSONStrPathRequired(json *json.RawMessage, path string, fieldPath string) (bool, *IValidMessage)

func (*BaseValidator) IsMongoExistsWithCondition

func (b *BaseValidator) IsMongoExistsWithCondition(
    ctx IContext,
    table string,
    filter interface{},
    fieldPath string,
) (bool, *IValidMessage)

func (*BaseValidator) IsMongoStrUnique

func (b *BaseValidator) IsMongoStrUnique(ctx IContext, table string, filter interface{}, fieldPath string) (bool, *IValidMessage)

func (*BaseValidator) IsNotEmptyObjectRequired

func (b *BaseValidator) IsNotEmptyObjectRequired(value interface{}, fieldPath string) (bool, *IValidMessage)

func (*BaseValidator) IsNumberBetween

func (b *BaseValidator) IsNumberBetween(field *int64, min int64, max int64, fieldPath string) (bool, *IValidMessage)

func (*BaseValidator) IsNumberMax

func (b *BaseValidator) IsNumberMax(field *int64, max int64, fieldPath string) (bool, *IValidMessage)

func (*BaseValidator) IsNumberMin

func (b *BaseValidator) IsNumberMin(field *int64, min int64, fieldPath string) (bool, *IValidMessage)

func (*BaseValidator) IsRequired

func (b *BaseValidator) IsRequired(field interface{}, fieldPath string) (bool, *IValidMessage)

func (*BaseValidator) IsRequiredArray

func (b *BaseValidator) IsRequiredArray(array interface{}, fieldPath string) (bool, *IValidMessage)

func (*BaseValidator) IsStrIn

func (b *BaseValidator) IsStrIn(input *string, rules string, fieldPath string) (bool, *IValidMessage)

func (*BaseValidator) IsStrMax

func (b *BaseValidator) IsStrMax(input *string, size int, fieldPath string) (bool, *IValidMessage)

func (*BaseValidator) IsStrMin

func (b *BaseValidator) IsStrMin(input *string, size int, fieldPath string) (bool, *IValidMessage)

func (*BaseValidator) IsStrRequired

func (b *BaseValidator) IsStrRequired(field *string, fieldPath string) (bool, *IValidMessage)

func (*BaseValidator) IsStrUnique

func (b *BaseValidator) IsStrUnique(ctx IContext, field *string, table string, column string, except string, fieldPath string) (bool, *IValidMessage)

func (*BaseValidator) IsStringContain

func (b *BaseValidator) IsStringContain(field *string, substr string, fieldPath string) (bool, *IValidMessage)

func (*BaseValidator) IsStringEndWith

func (b *BaseValidator) IsStringEndWith(field *string, substr string, fieldPath string) (bool, *IValidMessage)

func (*BaseValidator) IsStringLowercase

func (b *BaseValidator) IsStringLowercase(field *string, fieldPath string) (bool, *IValidMessage)

func (*BaseValidator) IsStringNotContain

func (b *BaseValidator) IsStringNotContain(field *string, substr string, fieldPath string) (bool, *IValidMessage)

func (*BaseValidator) IsStringNumber

func (b *BaseValidator) IsStringNumber(field *string, fieldPath string) (bool, *IValidMessage)

func (*BaseValidator) IsStringNumberMin

func (b *BaseValidator) IsStringNumberMin(field *string, min int64, fieldPath string) (bool, *IValidMessage)

func (*BaseValidator) IsStringStartWith

func (b *BaseValidator) IsStringStartWith(field *string, substr string, fieldPath string) (bool, *IValidMessage)

func (*BaseValidator) IsStringUppercase

func (b *BaseValidator) IsStringUppercase(field *string, fieldPath string) (bool, *IValidMessage)

func (*BaseValidator) IsTime

func (b *BaseValidator) IsTime(input *string, fieldPath string) (bool, *IValidMessage)

func (*BaseValidator) IsTimeAfter

func (b *BaseValidator) IsTimeAfter(input *string, after *string, fieldPath string) (bool, *IValidMessage)

func (*BaseValidator) IsTimeBefore

func (b *BaseValidator) IsTimeBefore(input *string, before *string, fieldPath string) (bool, *IValidMessage)

func (*BaseValidator) IsTimeRequired

func (b *BaseValidator) IsTimeRequired(field *time.Time, fieldPath string) (bool, *IValidMessage)

func (*BaseValidator) IsURL

func (b *BaseValidator) IsURL(field *string, fieldPath string) (bool, *IValidMessage)

func (*BaseValidator) LoopJSONArray

func (b *BaseValidator) LoopJSONArray(j *json.RawMessage) []interface{}

func (*BaseValidator) Merge

func (b *BaseValidator) Merge(errs ...*Valid) IError

func (*BaseValidator) Must

func (b *BaseValidator) Must(condition bool, msg *IValidMessage) bool

func (*BaseValidator) SetPrefix

func (b *BaseValidator) SetPrefix(prefix string)

type ContextMock

type ContextMock struct {
    mock.Mock
    MockRequester *MockRequester
    MockCache     *MockCache
    MockMQ        *MockMQ
    MockLog       *MockLogger
    MockDBMongo   *MockMongoDB
    MockDB        *MockDatabase
}

func NewMockContext

func NewMockContext() *ContextMock

func (*ContextMock) Cache

func (m *ContextMock) Cache() ICache

func (*ContextMock) Caches

func (m *ContextMock) Caches(name string) ICache

func (*ContextMock) DB

func (m *ContextMock) DB() *gorm.DB

func (*ContextMock) DBMongo

func (m *ContextMock) DBMongo() IMongoDB

func (*ContextMock) DBS

func (m *ContextMock) DBS(name string) *gorm.DB

func (*ContextMock) DBSMongo

func (m *ContextMock) DBSMongo(name string) IMongoDB

func (*ContextMock) ENV

func (m *ContextMock) ENV() IENV

func (*ContextMock) Log

func (m *ContextMock) Log() ILogger

Log return the logger

func (*ContextMock) MQ

func (m *ContextMock) MQ() IMQ

func (*ContextMock) NewError

func (m *ContextMock) NewError(err error, errorType IError, args ...interface{}) IError

func (*ContextMock) Requester

func (m *ContextMock) Requester() IRequester

func (*ContextMock) SetType

func (m *ContextMock) SetType(t consts.ContextType)

func (*ContextMock) Type

func (m *ContextMock) Type() string

type ContextOptions

type ContextOptions struct {
    DB       *gorm.DB
    DBS      map[string]*gorm.DB
    MongoDB  IMongoDB
    MongoDBS map[string]IMongoDB
    Cache    ICache
    Caches   map[string]ICache
    ENV      IENV
    MQ       IMQ

    DATA map[string]interface{}
    // contains filtered or unexported fields
}

type ContextUser

type ContextUser struct {
    ID       string            `json:"id,omitempty"`
    Email    string            `json:"email,omitempty"`
    Username string            `json:"username,omitempty"`
    Name     string            `json:"name,omitempty"`
    Segment  string            `json:"segment,omitempty"`
    Data     map[string]string `json:"data,omitempty"`
}

type CronjobContext

type CronjobContext struct {
    IContext
    // contains filtered or unexported fields
}

func (CronjobContext) AddJob

func (c CronjobContext) AddJob(job *gocron.Scheduler, handlerFunc func(ctx ICronjobContext) error)

func (CronjobContext) Job

func (c CronjobContext) Job() *gocron.Scheduler

func (CronjobContext) Start

func (c CronjobContext) Start()

type CronjobContextOptions

type CronjobContextOptions struct {
    ContextOptions *ContextOptions
    TimeLocation   *time.Location
}

type Database

type Database struct {
    Driver   string
    Name     string
    Host     string
    User     string
    Password string
    Port     string
    // contains filtered or unexported fields
}

func NewDatabase

func NewDatabase(env *ENVConfig) *Database

func NewDatabaseWithConfig

func NewDatabaseWithConfig(env *ENVConfig, config *gorm.Config) *Database

func (*Database) Connect

func (db *Database) Connect() (*gorm.DB, error)

Connect to connect Database

type DatabaseCache

type DatabaseCache struct {
    Host string
    Port string
}

func NewCache

func NewCache(env *ENVConfig) *DatabaseCache

func (DatabaseCache) Connect

func (r DatabaseCache) Connect() (ICache, error)

type DatabaseMongo

type DatabaseMongo struct {
    Name     string
    Host     string
    UserName string
    Password string
    Port     string
}

func NewDatabaseMongo

func NewDatabaseMongo(env *ENVConfig) *DatabaseMongo

func (*DatabaseMongo) Connect

func (db *DatabaseMongo) Connect() (IMongoDB, error)

Connect to connect Database

type E2EContext

type E2EContext struct {
    IContext
}

type E2EContextOptions

type E2EContextOptions struct {
    ContextOptions *ContextOptions
}

type ENVConfig

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"`
}

type ENVType

type ENVType struct {
    // contains filtered or unexported fields
}

func (ENVType) All

func (e ENVType) All() map[string]string

func (ENVType) Bool

func (e ENVType) Bool(key string) bool

func (ENVType) Config

func (e ENVType) Config() *ENVConfig

func (ENVType) Int

func (e ENVType) Int(key string) int

func (ENVType) IsDev

func (e ENVType) IsDev() bool

IsDev config is Dev config

func (ENVType) IsMock

func (e ENVType) IsMock() bool

func (ENVType) IsProd

func (e ENVType) IsProd() bool

IsProd config is production config

func (ENVType) IsTest

func (e ENVType) IsTest() bool

IsTest config is Test config

func (ENVType) String

func (e ENVType) String(key string) string

type Error

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) Error

func (c Error) Error() string

func (Error) GetCode

func (c Error) GetCode() string

func (Error) GetMessage

func (c Error) GetMessage() interface{}

func (Error) GetStatus

func (c Error) GetStatus() int

func (Error) JSON

func (c Error) JSON() interface{}

func (Error) OriginalError

func (c Error) OriginalError() error

type FieldError

type FieldError struct {
    Code    string      `json:"code"`
    Message string      `json:"message"`
    Fields  interface{} `json:"fields,omitempty"`
}

func (FieldError) Error

func (f FieldError) Error() string

func (FieldError) GetCode

func (f FieldError) GetCode() string

func (FieldError) GetMessage

func (f FieldError) GetMessage() interface{}

func (FieldError) GetStatus

func (FieldError) GetStatus() int

func (FieldError) JSON

func (f FieldError) JSON() interface{}

func (FieldError) OriginalError

func (f FieldError) OriginalError() error

func (FieldError) OriginalErrorMessage

func (f FieldError) OriginalErrorMessage() string

type File

type File struct {
    // contains filtered or unexported fields
}

func (File) Name

func (f File) Name() string

func (File) Value

func (f File) Value() []byte

type HTTPContext

type HTTPContext struct {
    echo.Context
    IContext
    // contains filtered or unexported fields
}

func (*HTTPContext) BindOnly

func (c *HTTPContext) BindOnly(i interface{}) IError

func (*HTTPContext) BindWithValidate

func (c *HTTPContext) BindWithValidate(ctx IValidateContext) IError

func (*HTTPContext) BindWithValidateMessage

func (c *HTTPContext) BindWithValidateMessage(ctx IValidateContext) IError

func (*HTTPContext) GetMessage

func (c *HTTPContext) GetMessage() string

func (*HTTPContext) GetPageOptions

func (c *HTTPContext) GetPageOptions() *PageOptions

func (*HTTPContext) GetPageOptionsWithOptions

func (c *HTTPContext) GetPageOptionsWithOptions(options *PageOptionsOptions) *PageOptions

func (*HTTPContext) GetSignature

func (c *HTTPContext) GetSignature() string

func (HTTPContext) GetUserAgent

func (c HTTPContext) GetUserAgent() *user_agent.UserAgent

func (*HTTPContext) Log

func (c *HTTPContext) Log() ILogger

func (*HTTPContext) NewError

func (c *HTTPContext) NewError(err error, errorType IError, args ...interface{}) IError

func (*HTTPContext) WithSaveCache

func (c *HTTPContext) WithSaveCache(data interface{}, key string, duration time.Duration) interface{}

type HTTPContextOptions

type HTTPContextOptions struct {
    RateLimit      *middleware.RateLimiterMemoryStoreConfig
    AllowOrigins   []string
    ContextOptions *ContextOptions
}

type HandlerFunc

type HandlerFunc func(IHTTPContext) error

type IABCIContext

type IABCIContext interface {
    IContext
    GetOperation(tx []byte) string
    GetMessageJSON(tx []byte) string
}

func NewABCIContext

func NewABCIContext(options *ABCIContextOptions) IABCIContext

type IArchiver

type IArchiver interface {
    FromURLs(fileName string, urls []string, options *ArchiverOptions) ([]byte, IError)
    FromBytes(fileName string, body []ArchiveByteBody, options *ArchiverOptions) ([]byte, IError)
}

func NewArchiver

func NewArchiver(ctx IContext) IArchiver

type ICSV

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)
}

func NewCSV

func NewCSV[T any](ctx IContext) ICSV[T]

type ICSVOptions

type ICSVOptions struct {
    FirstRowIsHeader bool
    Separator        string
}

type ICache

type ICache interface {
    Set(key string, value interface{}, expiration time.Duration) error
    SetJSON(key string, value interface{}, expiration time.Duration) error
    Get(dest interface{}, key string) error
    GetJSON(dest interface{}, key string) error
    Del(key string) error
    Close()
}

type IContext

type IContext interface {
    MQ() IMQ
    DB() *gorm.DB
    DBS(name string) *gorm.DB
    DBMongo() IMongoDB
    DBSMongo(name string) IMongoDB
    WinRM() IWinRM
    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

func NewContext(options *ContextOptions) IContext

type ICronjobContext

type ICronjobContext interface {
    IContext
    Job() *gocron.Scheduler
    Start()
    AddJob(job *gocron.Scheduler, handlerFunc func(ctx ICronjobContext) error)
}

func NewCronjobContext

func NewCronjobContext(options *CronjobContextOptions) ICronjobContext

type IE2EContext

type IE2EContext interface {
    IContext
}

func NewE2EContext

func NewE2EContext(options *E2EContextOptions) IE2EContext

type IENV

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

func NewENVPath(path string) IENV

func NewEnv

func NewEnv() IENV

type IEmail

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)
}

func NewEmail

func NewEmail(ctx IContext) IEmail

type IError

type IError interface {
    Error() string
    GetCode() string
    GetStatus() int
    JSON() interface{}
    OriginalError() error
    GetMessage() interface{}
}

func DBErrorToIError

func DBErrorToIError(err error) IError

func MockIError

func MockIError(args mock.Arguments, index int) IError

func NewValidatorFields

func NewValidatorFields(fields interface{}) IError

func RequesterToStruct

func RequesterToStruct(desc interface{}, requester func() (*RequestResponse, error)) IError

type IFile

type IFile interface {
    Name() string
    Value() []byte
}

func NewFile

func NewFile(name string, value []byte) IFile

type IHTTPContext

type IHTTPContext interface {
    IContext
    echo.Context
    BindWithValidate(ctx IValidateContext) IError
    BindWithValidateMessage(ctx IValidateContext) IError
    BindOnly(i interface{}) IError
    GetSignature() string
    GetMessage() string
    GetPageOptions() *PageOptions
    GetPageOptionsWithOptions(options *PageOptionsOptions) *PageOptions
    GetUserAgent() *user_agent.UserAgent
    WithSaveCache(data interface{}, key string, duration time.Duration) interface{}
}

func NewHTTPContext

func NewHTTPContext(ctx echo.Context, options *HTTPContextOptions) IHTTPContext

type ILogger

type ILogger interface {
    Info(args ...interface{})
    Warn(args ...interface{})
    Debug(args ...interface{})
    DebugWithSkip(skip int, args ...interface{})
    Error(message error, args ...interface{})
    ErrorWithSkip(skip int, message error, args ...interface{})
}

type IMQ

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

type IMQContext interface {
    IContext
    AddConsumer(handlerFunc func(ctx IMQContext))
    Consume(name string, onConsume func(message amqp.Delivery), options *MQConsumeOptions)
    Start()
}

func NewMQContext

func NewMQContext(options *MQContextOptions) IMQContext

func NewMQServer

func NewMQServer(options *MQContextOptions) IMQContext

type IMongoDB

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 *PageOptions, opts ...*options.AggregateOptions) (*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 *PageOptions, opts ...*options.FindOptions) (*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

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

func NewMongoHelper() IMongoDBHelper

type IMongoIndexBatch

type IMongoIndexBatch interface {
    Name() string
    Run() error
}

type IMongoIndexer

type IMongoIndexer interface {
    Add(batch IMongoIndexBatch)
    Execute() error
}

func NewMongoIndexer

func NewMongoIndexer(ctx IContext) IMongoIndexer

type IRequester

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 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

func NewRequester(ctx IContext) IRequester

type IS3

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 ISeed

type ISeed interface {
    Run() error
}

type IValidMessage

type IValidMessage struct {
    Name    string      `json:"-"`
    Code    string      `json:"code"`
    Message string      `json:"message"`
    Data    interface{} `json:"data,omitempty"`
}

func (IValidMessage) Error

func (f IValidMessage) Error() string

type IValidate

type IValidate interface {
    Valid() IError
}

type IValidateContext

type IValidateContext interface {
    Valid(ctx IContext) IError
}

type IWinRM

type IWinRM interface {
    Command(command string, isProduction bool) (*WinRMResult, IError)
}

func NewWinRM

func NewWinRM(ctx IContext) IWinRM

type KeywordCondition

type KeywordCondition string

type KeywordConditionWrapper

type KeywordConditionWrapper struct {
    Condition      KeywordCondition
    KeywordOptions []KeywordOptions
}

func NewKeywordAndCondition

func NewKeywordAndCondition(keywordOptions []KeywordOptions) *KeywordConditionWrapper

func NewKeywordOrCondition

func NewKeywordOrCondition(keywordOptions []KeywordOptions) *KeywordConditionWrapper

type KeywordOptions

type KeywordOptions struct {
    Type  KeywordType
    Key   string
    Value string
}

func NewKeywordMustMatchOption

func NewKeywordMustMatchOption(key string, value string) *KeywordOptions

func NewKeywordMustMatchOptions

func NewKeywordMustMatchOptions(keys []string, value string) []KeywordOptions

func NewKeywordWildCardOption

func NewKeywordWildCardOption(key string, value string) *KeywordOptions

func NewKeywordWildCardOptions

func NewKeywordWildCardOptions(keys []string, value string) []KeywordOptions

type KeywordType

type KeywordType string

type Logger

Log is the logger utility with information of request context

type Logger struct {
    RequestID string
    HostName  string

    Type consts.ContextType
    // contains filtered or unexported fields
}

func NewLogger

func NewLogger(ctx IContext) *Logger

NewLogger will create the logger with context from echo context

func NewLoggerSimple

func NewLoggerSimple() *Logger

NewLoggerSimple return plain text simple logger

func (*Logger) Debug

func (logger *Logger) Debug(args ...interface{})

Debug log debug level

func (*Logger) DebugWithSkip

func (logger *Logger) DebugWithSkip(skip int, args ...interface{})

func (*Logger) Error

func (logger *Logger) Error(message error, args ...interface{})

Error log error level

func (*Logger) ErrorWithSkip

func (logger *Logger) ErrorWithSkip(skip int, message error, args ...interface{})

Error log error level

func (*Logger) Info

func (logger *Logger) Info(args ...interface{})

Info log information level

func (*Logger) Warn

func (logger *Logger) Warn(args ...interface{})

Warn log warnning level

type MQ

type MQ struct {
    Host     string
    User     string
    Password string
    Port     string
    LogLevel logrus.Level
}

func NewMQ

func NewMQ(env *ENVConfig) *MQ

func (*MQ) Connect

func (m *MQ) Connect() (IMQ, error)

ConnectDB to connect Database

func (*MQ) ReConnect

func (m *MQ) ReConnect() (*amqp.Connection, error)

ConnectDB to connect Database

type MQConsumeOptions

type MQConsumeOptions struct {
    Durable    bool
    AutoDelete bool
    Exclusive  bool
    NoWait     bool
    Args       amqp.Table
    AutoAck    bool
    NoLocal    bool
    Consumer   string
}

type MQContext

type MQContext struct {
    IContext
}

func (*MQContext) AddConsumer

func (c *MQContext) AddConsumer(handlerFunc func(ctx IMQContext))

func (*MQContext) Consume

func (c *MQContext) Consume(name string, onConsume func(message amqp.Delivery), options *MQConsumeOptions)

func (*MQContext) Start

func (c *MQContext) Start()

type MQContextOptions

type MQContextOptions struct {
    ContextOptions *ContextOptions
}

type MQPublishOptions

type MQPublishOptions struct {
    Exchange     string
    MessageID    string
    Durable      bool
    AutoDelete   bool
    Exclusive    bool
    Mandatory    bool
    Immediate    bool
    NoWait       bool
    DeliveryMode uint8
    Args         amqp.Table
}

type Map

type Map map[string]interface{}

type MockCache

type MockCache struct {
    mock.Mock
}

func NewMockCache

func NewMockCache() *MockCache

func (*MockCache) Close

func (m *MockCache) Close()

func (*MockCache) Del

func (m *MockCache) Del(key string) error

func (*MockCache) Get

func (m *MockCache) Get(dest interface{}, key string) error

func (*MockCache) GetJSON

func (m *MockCache) GetJSON(dest interface{}, key string) error

func (*MockCache) Set

func (m *MockCache) Set(key string, value interface{}, expiration time.Duration) error

func (*MockCache) SetJSON

func (m *MockCache) SetJSON(key string, value interface{}, expiration time.Duration) error

type MockDatabase

type MockDatabase struct {
    Gorm *gorm.DB
    Mock sqlmock.Sqlmock
}

func NewMockDatabase

func NewMockDatabase() *MockDatabase

type MockLogger

type MockLogger struct {
    mock.Mock
}

func NewMockLogger

func NewMockLogger() *MockLogger

func (*MockLogger) Debug

func (m *MockLogger) Debug(args ...interface{})

func (*MockLogger) Error

func (m *MockLogger) Error(message error, args ...interface{})

func (*MockLogger) Info

func (m *MockLogger) Info(args ...interface{})

func (*MockLogger) Warn

func (m *MockLogger) Warn(args ...interface{})

type MockMQ

type MockMQ struct {
    mock.Mock
}

func NewMockMQ

func NewMockMQ() *MockMQ

func (*MockMQ) Close

func (m *MockMQ) Close()

func (*MockMQ) Conn

func (m *MockMQ) Conn() *amqp.Connection

func (*MockMQ) Consume

func (m *MockMQ) Consume(name string, onConsume func(message amqp.Delivery), options *MQConsumeOptions) error

func (*MockMQ) PublishJSON

func (m *MockMQ) PublishJSON(name string, data interface{}, options *MQPublishOptions) error

type MockMiddlewareManual

type MockMiddlewareManual func(c IHTTPContext) error

type MockMiddlewareOptions

type MockMiddlewareOptions struct {
    Wrapper      MockMiddlewareWrapper
    Manual       MockMiddlewareManual
    IsPagination bool
    IsDisabled   bool
}

type MockMiddlewareWrapper

type MockMiddlewareWrapper func(model interface{}) interface{}

type MockMongoDB

type MockMongoDB struct {
    mock.Mock
}

func NewMockMongoDB

func NewMockMongoDB() *MockMongoDB

func (*MockMongoDB) Close

func (m *MockMongoDB) Close()

func (*MockMongoDB) Count

func (m *MockMongoDB) Count(coll string, filter interface{}, opts ...*options.CountOptions) (int64, error)

func (*MockMongoDB) Create

func (m *MockMongoDB) Create(coll string, document interface{}, opts ...*options.InsertOneOptions) (*mongo.InsertOneResult, error)

func (*MockMongoDB) DB

func (m *MockMongoDB) DB() *mongo.Database

func (*MockMongoDB) DeleteMany

func (m *MockMongoDB) DeleteMany(coll string, filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)

func (*MockMongoDB) DeleteOne

func (m *MockMongoDB) DeleteOne(coll string, filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)

func (*MockMongoDB) Drop

func (m *MockMongoDB) Drop(coll string) error

func (*MockMongoDB) Find

func (m *MockMongoDB) Find(dest interface{}, coll string, filter interface{}, opts ...*options.FindOptions) error

func (*MockMongoDB) FindAggregate

func (m *MockMongoDB) FindAggregate(dest interface{}, coll string, pipeline interface{}, opts ...*options.AggregateOptions) error

func (*MockMongoDB) FindAggregateOne

func (m *MockMongoDB) FindAggregateOne(dest interface{}, coll string, pipeline interface{}, opts ...*options.AggregateOptions) error

func (*MockMongoDB) FindAggregatePagination

func (m *MockMongoDB) FindAggregatePagination(dest interface{}, coll string, pipeline interface{}, pageOptions *PageOptions, opts ...*options.AggregateOptions) (*PageResponse, error)

func (*MockMongoDB) FindOne

func (m *MockMongoDB) FindOne(dest interface{}, coll string, filter interface{}, opts ...*options.FindOneOptions) error

func (*MockMongoDB) FindOneAndDelete

func (m *MockMongoDB) FindOneAndDelete(coll string, filter interface{}, opts ...*options.FindOneAndDeleteOptions) error

func (*MockMongoDB) FindOneAndUpdate

func (m *MockMongoDB) FindOneAndUpdate(dest interface{}, coll string, filter interface{}, update interface{},
    opts ...*options.FindOneAndUpdateOptions) error

func (*MockMongoDB) FindPagination

func (m *MockMongoDB) FindPagination(dest interface{}, coll string, filter interface{}, pageOptions *PageOptions, opts ...*options.FindOptions) (*PageResponse, error)

func (*MockMongoDB) Helper

func (m *MockMongoDB) Helper() IMongoDBHelper

func (*MockMongoDB) UpdateOne

func (m *MockMongoDB) UpdateOne(coll string, filter interface{}, update interface{},
    opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)

type MockMongoIndexBatch

type MockMongoIndexBatch struct {
    mock.Mock
}

func NewMockMongoIndexBatch

func NewMockMongoIndexBatch() *MockMongoIndexBatch

func (*MockMongoIndexBatch) Name

func (m *MockMongoIndexBatch) Name() string

func (*MockMongoIndexBatch) Run

func (m *MockMongoIndexBatch) Run() error

type MockMongoIndexer

type MockMongoIndexer struct {
    mock.Mock
    Batches []*MockMongoIndexBatch
}

func NewMockMongoIndexer

func NewMockMongoIndexer() *MockMongoIndexer

func (*MockMongoIndexer) Add

func (m *MockMongoIndexer) Add(batch *MockMongoIndexBatch)

func (*MockMongoIndexer) Execute

func (m *MockMongoIndexer) Execute() error

type MockRequester

type MockRequester struct {
    mock.Mock
}

func NewMockRequester

func NewMockRequester() *MockRequester

func (*MockRequester) Delete

func (m *MockRequester) Delete(url string, options *RequesterOptions) (*RequestResponse, error)

func (*MockRequester) Get

func (m *MockRequester) Get(url string, options *RequesterOptions) (*RequestResponse, error)

func (*MockRequester) Patch

func (m *MockRequester) Patch(url string, body interface{}, options *RequesterOptions) (*RequestResponse, error)

func (*MockRequester) Post

func (m *MockRequester) Post(url string, body interface{}, options *RequesterOptions) (*RequestResponse, error)

func (*MockRequester) Put

func (m *MockRequester) Put(url string, body interface{}, options *RequesterOptions) (*RequestResponse, error)

type MongoDB

type MongoDB struct {
    // contains filtered or unexported fields
}

func (MongoDB) Close

func (m MongoDB) Close()

func (MongoDB) Count

func (m MongoDB) Count(coll string, filter interface{}, opts ...*options.CountOptions) (int64, error)

func (MongoDB) Create

func (m MongoDB) Create(coll string, document interface{}, opts ...*options.InsertOneOptions) (*mongo.InsertOneResult, error)

func (MongoDB) CreateIndex

func (m MongoDB) CreateIndex(coll string, models []mongo.IndexModel, opts ...*options.CreateIndexesOptions) ([]string, error)

func (MongoDB) DB

func (m MongoDB) DB() *mongo.Database

func (MongoDB) DeleteMany

func (m MongoDB) DeleteMany(coll string, filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)

func (MongoDB) DeleteOne

func (m MongoDB) DeleteOne(coll string, filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)

func (MongoDB) Drop

func (m MongoDB) Drop(coll string) error

func (MongoDB) DropAll

func (m MongoDB) DropAll(coll string, opts ...*options.DropIndexesOptions) (*MongoDropIndexResult, error)

func (MongoDB) DropIndex

func (m MongoDB) DropIndex(coll string, name string, opts ...*options.DropIndexesOptions) (*MongoDropIndexResult, error)

func (MongoDB) Find

func (m MongoDB) Find(dest interface{}, coll string, filter interface{}, opts ...*options.FindOptions) error

func (MongoDB) FindAggregate

func (m MongoDB) FindAggregate(dest interface{}, coll string, pipeline interface{}, opts ...*options.AggregateOptions) error

func (MongoDB) FindAggregateOne

func (m MongoDB) FindAggregateOne(dest interface{}, coll string, pipeline interface{}, opts ...*options.AggregateOptions) error

func (MongoDB) FindAggregatePagination

func (m MongoDB) FindAggregatePagination(dest interface{}, coll string, pipeline interface{}, pageOptions *PageOptions, opts ...*options.AggregateOptions) (*PageResponse, error)

func (MongoDB) FindOne

func (m MongoDB) FindOne(dest interface{}, coll string, filter interface{}, opts ...*options.FindOneOptions) error

func (MongoDB) FindOneAndDelete

func (m MongoDB) FindOneAndDelete(coll string, filter interface{}, opts ...*options.FindOneAndDeleteOptions) error

func (MongoDB) FindOneAndUpdate

func (m MongoDB) FindOneAndUpdate(dest interface{}, coll string, filter interface{}, update interface{},
    opts ...*options.FindOneAndUpdateOptions) error

func (MongoDB) FindPagination

func (m MongoDB) FindPagination(dest interface{}, coll string, filter interface{}, pageOptions *PageOptions, opts ...*options.FindOptions) (*PageResponse, error)

func (MongoDB) Helper

func (m MongoDB) Helper() IMongoDBHelper

func (MongoDB) ListIndex

func (m MongoDB) ListIndex(coll string, opts ...*options.ListIndexesOptions) ([]MongoListIndexResult, error)

func (MongoDB) UpdateOne

func (m MongoDB) UpdateOne(coll string, filter interface{}, update interface{},
    opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)

type MongoDropIndexResult

type MongoDropIndexResult struct {
    DropCount int64 `json:"drop_count" bson:"nIndexesWas"`
}

type MongoFilterOptions

type MongoFilterOptions struct {
    Input     string
    As        string
    Condition bson.M
}

type MongoIndexer

type MongoIndexer struct {
    Batches []IMongoIndexBatch
    // contains filtered or unexported fields
}

func (*MongoIndexer) Add

func (i *MongoIndexer) Add(batch IMongoIndexBatch)

func (*MongoIndexer) Execute

func (i *MongoIndexer) Execute() error

type MongoListIndexResult

type MongoListIndexResult struct {
    Key     map[string]int64 `json:"key" bson:"key"`
    Name    string           `json:"name" bson:"name"`
    Version int64            `json:"version" bson:"v"`
}

type MongoLookupOptions

type MongoLookupOptions struct {
    From         string
    LocalField   string
    ForeignField string
    As           string
}

type PageOptions

type PageOptions struct {
    Q       string
    Limit   int64
    Page    int64
    OrderBy []string
}

func (*PageOptions) SetOrderDefault

func (p *PageOptions) SetOrderDefault(orders ...string)

type PageOptionsOptions

type PageOptionsOptions struct {
    OrderByAllowed []string
}

type PageResponse

type PageResponse struct {
    Total   int64
    Limit   int64
    Count   int64
    Page    int64
    Q       string
    OrderBy []string
}

func Paginate

func Paginate(db *gorm.DB, model interface{}, options *PageOptions) (*PageResponse, error)

type Pagination

type Pagination struct {
    Page  int64       `json:"page" example:"1"`
    Total int64       `json:"total" example:"45"`
    Limit int64       `json:"limit" example:"30"`
    Count int64       `json:"count" example:"30"`
    Items interface{} `json:"items"`
}

func NewPagination

func NewPagination(items interface{}, options *PageResponse) *Pagination

type RequestResponse

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

func RequestWrapper(dest interface{}, requester func() (*RequestResponse, error)) (*RequestResponse, error)

Deprecated: RequestWrapper is deprecated, use RequestToStruct or RequestToStructPagination instead.

type Requester

type Requester struct {
    // contains filtered or unexported fields
}

func (Requester) Create

func (r Requester) Create(method RequesterMethodType, url string, body interface{}, options *RequesterOptions) (*RequestResponse, error)

func (Requester) Delete

func (r Requester) Delete(url string, options *RequesterOptions) (*RequestResponse, error)

func (Requester) Get

func (r Requester) Get(url string, options *RequesterOptions) (*RequestResponse, error)

func (Requester) Patch

func (r Requester) Patch(url string, body interface{}, options *RequesterOptions) (*RequestResponse, error)

func (Requester) Post

func (r Requester) Post(url string, body interface{}, options *RequesterOptions) (*RequestResponse, error)

func (Requester) Put

func (r Requester) Put(url string, body interface{}, options *RequesterOptions) (*RequestResponse, error)

type RequesterMethodType

type RequesterMethodType string
const (
    RequesterMethodTypeGET     RequesterMethodType = http.MethodGet
    RequesterMethodTypeHEAD    RequesterMethodType = http.MethodHead
    RequesterMethodTypePOST    RequesterMethodType = http.MethodPost
    RequesterMethodTypePUT     RequesterMethodType = http.MethodPut
    RequesterMethodTypePATCH   RequesterMethodType = http.MethodPatch
    RequesterMethodTypeDELETE  RequesterMethodType = http.MethodDelete
    RequesterMethodTypeOPTIONS RequesterMethodType = http.MethodOptions
    RequesterMethodTypeTRACE   RequesterMethodType = http.MethodTrace
)

type RequesterOptions

type RequesterOptions struct {
    BaseURL         string
    Timeout         *time.Duration
    Headers         http.Header
    Params          xurl.Values
    RetryCount      int
    IsMultipartForm bool
    IsURLEncode     bool
    IsBodyRawByte   bool
}

type S3Config

type S3Config struct {
    Endpoint  string
    AccessKey string
    SecretKey string
    Bucket    string
    Region    string
    IsHTTPS   bool
}

func NewS3

func NewS3(env *ENVConfig) *S3Config

func (*S3Config) Connect

func (r *S3Config) Connect() (IS3, error)

type Seeder

type Seeder struct {
}

func NewSeeder

func NewSeeder() *Seeder

func (Seeder) Add

func (receiver Seeder) Add(seeder ISeed) error

type UploadOptions

type UploadOptions struct {
    Width   int64
    Height  int64
    Quality int64
}

type Valid

Validator type

type Valid struct {
    // contains filtered or unexported fields
}

func NewValid

func NewValid() *Valid

New creates new validator

func (*Valid) Add

func (v *Valid) Add(err ...error)

Add adds errors

func (*Valid) Error

func (v *Valid) Error() string

Error returns error if has error

func (*Valid) GetCode

func (v *Valid) GetCode() string

func (*Valid) GetMessage

func (v *Valid) GetMessage() interface{}

func (*Valid) GetStatus

func (v *Valid) GetStatus() int

func (*Valid) JSON

func (v *Valid) JSON() interface{}

func (*Valid) Must

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

func (v *Valid) OriginalError() error

func (*Valid) OriginalErrorMessage

func (v *Valid) OriginalErrorMessage() string

func (*Valid) Valid

func (v *Valid) Valid() IError

Valid returns true if no error

type ValidError

Error is the validate error

type ValidError struct {
    // contains filtered or unexported fields
}

func (*ValidError) Error

func (err *ValidError) Error() string

Error implements error interface

func (*ValidError) Errors

func (err *ValidError) Errors() []error

Errors returns errors

func (*ValidError) Strings

func (err *ValidError) Strings() []string

Strings returns errors in strings

type Validator

type Validator struct{}

func (*Validator) Validate

func (cv *Validator) Validate(i interface{}) error

type WinRM

type WinRM struct {
    // contains filtered or unexported fields
}

func (*WinRM) Command

func (w *WinRM) Command(command string, isProduction bool) (*WinRMResult, IError)

type WinRMResult

type WinRMResult struct {
    Result string `json:"result"`
}

Subdirectories

Name Synopsis
..
consts
errmsgs
utils