Documentation ¶
Index ¶
- Constants
- func Configuration(osFile *os.File, model interface{}) error
- func CreateJWT(req RequestCreateJWT) (token string, err error)
- func Gomail(host, password string, port int, from, to, subject, message string) error
- func LogMiddleware(logger Logs) func(c *gin.Context)
- func NewGorm(db *sql.DB, driverName string, level logLevel) (*gorm.DB, error)
- func NewMySQL(user, password, url, schema string, parameters []string) (*sql.DB, error)
- func NewPostgreSQL(user, password, host, schema string, sslMode null.String, port int) (*sql.DB, error)
- func NewSqlx(db *sql.DB, driverName string) *sqlx.DB
- func OpenFile(path, filename string) (*os.File, error)
- func OpenFileNewest(oldest *os.File, path, filename string) (*os.File, error)
- func Pagination(limit, offset int) (limits, offsets int)
- func ParseContext(c *gin.Context) context.Context
- func ParseJWT(key string, signMethod jwt.SigningMethod, attributesJWT []string) func(c *gin.Context)
- func RandIntRunes(n int) string
- func RandStringRunes(n int) string
- func ResponseError(c *gin.Context, code int, msg error, obj interface{})
- func ResponseOK(c *gin.Context, code int, obj interface{})
- func SetContext(c *gin.Context)
- func TimeFormat(t time.Time, tf int) string
- func TimeParse(s string, tl int) time.Time
- type BasicAuth
- type BasicAuthPayload
- type Context
- type Key
- type KeyContext
- type Logs
- type RESTful
- type RegisterTranslation
- type RegisterValidation
- type RequestCreateJWT
- type RequestPayload
- type Response
- type TeleService
- type Validation
- func (vt *Validation) RegisterTranslation(translations ...RegisterTranslation) (err error)
- func (vt *Validation) RegisterValidation(validations ...RegisterValidation) (err error)
- func (vt *Validation) ValidationStruct(req interface{}) error
- func (vt *Validation) ValidationVariable(req interface{}, tag string, msgErr string) error
Constants ¶
const ( LoggerSilent = logLevel(logger.Silent) LoggerError = logLevel(logger.Error) LoggerWarn = logLevel(logger.Warn) LoggerInfo = logLevel(logger.Info) )
const ( ContentTypeJSON contentType = "application/json" ContentTypeFormURLEncoded contentType = "application/x-www-form-urlencoded" ContentTypeTextHTML contentType = "text/html" ContentTypeMultipartFormData contentType = "multipart/form-data" )
const MainToken = "main-token"
const RefreshToken = "refresh-token"
Variables ¶
This section is empty.
Functions ¶
func Configuration ¶
Configuration is a function for get info configuration
func CreateJWT ¶
func CreateJWT(req RequestCreateJWT) (token string, err error)
CreateJWT is a function for generate token
func NewGorm ¶
NewGorm is a override sql from native sql to gorm. driverName is a package of database your using, currently we have only mysql package. level is a info log of query, value is 1 - 4 (Silent, Error, Warn & Info)
func NewPostgreSQL ¶ added in v0.3.33
func NewPostgreSQL(user, password, host, schema string, sslMode null.String, port int) (*sql.DB, error)
NewPostgreSQL is a function for set up db postgresql connection
func OpenFileNewest ¶
OpenFileNewest is a function for open file with path & filename and close the oldest os.File
func Pagination ¶
Pagination is a function for calculate of limit & offset
func ParseContext ¶
ParseContext is a function for parsing gin.Context to context.Context
func ParseJWT ¶
func ParseJWT(key string, signMethod jwt.SigningMethod, attributesJWT []string) func(c *gin.Context)
ParseJWT is a function for parse of token string
func RandStringRunes ¶
RandStringRunes is a function for random string
func ResponseError ¶
ResponseError is a function for send result error to client
func ResponseOK ¶
ResponseOK is a function for send result to client
func TimeFormat ¶
TimeFormat is a function for formating from type data time.Time to type data string you can pick one the layout, format time layout : 1. "2006-01-02 15:04:05" 2. "2006-01-02" 3. "02 January 2006"
Types ¶
type BasicAuthPayload ¶ added in v0.0.14
type KeyContext ¶ added in v0.3.41
type KeyContext string
type Logs ¶
type Logs interface { Config(osFile *os.File, createOutput bool) Info(ctx context.Context, msg string, zapFields ...zapcore.Field) Warning(ctx context.Context, err error) Error(ctx context.Context, err error) Undo() Sync() }
Logs is a interface of method logging
type RESTful ¶ added in v0.0.13
type RESTful struct {
// contains filtered or unexported fields
}
func NewRESTful ¶ added in v0.0.13
func (*RESTful) Request ¶ added in v0.0.13
func (r *RESTful) Request(req RequestPayload) (statusCode int, err error)
func (*RESTful) RequestBasicAuth ¶ added in v0.0.14
func (r *RESTful) RequestBasicAuth(req BasicAuthPayload) (statusCode int, err error)
type RegisterTranslation ¶ added in v0.3.36
type RegisterTranslation func(v *validator.Validate, trans *ut.Translator) error
type RegisterValidation ¶ added in v0.3.36
type RegisterValidation func(v *validator.Validate) error
type RequestCreateJWT ¶ added in v0.3.41
type RequestCreateJWT struct { SignMethod jwt.SigningMethod Key string Data jwt.MapClaims }
type RequestPayload ¶ added in v0.0.12
type Response ¶
type Response struct { Code int `json:"code"` Message interface{} `json:"message"` Data interface{} `json:"data"` }
type TeleService ¶
type TeleService interface {
SendError(ctx context.Context, path string, line int, msg string) (err error)
}
TeleService is a interface all of function third-party Telegram
type Validation ¶
type Validation struct {
// contains filtered or unexported fields
}
func NewValidation ¶
func NewValidation() (Validation, error)
func (*Validation) RegisterTranslation ¶ added in v0.3.37
func (vt *Validation) RegisterTranslation(translations ...RegisterTranslation) (err error)
func (*Validation) RegisterValidation ¶ added in v0.3.37
func (vt *Validation) RegisterValidation(validations ...RegisterValidation) (err error)
func (*Validation) ValidationStruct ¶
func (vt *Validation) ValidationStruct(req interface{}) error
func (*Validation) ValidationVariable ¶
func (vt *Validation) ValidationVariable(req interface{}, tag string, msgErr string) error