Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( AvailableStatusOnline = "online" AvailableStatusOffline = "offline" )
View Source
var (
CF = &Configs{}
)
View Source
var (
RR = &ReturnResult{}
)
RR -> for use to return result model
Functions ¶
Types ¶
type AvailableConfig ¶
type AvailableConfig struct {
Status string `json:"status"`
}
type Configs ¶
type Configs struct { UniversalTranslator *ut.UniversalTranslator Validator *validator.Validate Path string App struct { AvailableStatus string // สถานะปิด/เปิดระบบ [on/off] ProjectId string `mapstructure:"PROJECT_ID"` ProjectName string `mapstructure:"PROJECT_NAME"` Version string `mapstructure:"VERSION"` WebBaseUrl string `mapstructure:"WEB_BASE_URL"` ApiBaseUrl string `mapstructure:"API_BASE_URL"` Port int `mapstructure:"PORT"` Environment Environment `mapstructure:"ENVIRONMENT"` Issuer string `mapstructure:"ISSUER"` Sources []UserPassConfig `mapstructure:"SOURCES"` } `mapstructure:"APP"` HTTPServer struct { Prefork bool `mapstructure:"PREFORK"` RateLimit struct { Max int `mapstructure:"MAX"` Expiration time.Duration `mapstructure:"EXPIRATION"` Enable bool `mapstructure:"ENABLE"` } `mapstructure:"RATELIMIT"` } `mapstructure:"HTTP_SERVER"` Web struct { DateFormat string `mapstructure:"DATE_FORMAT"` DateTimeFormat string `mapstructure:"DATETIME_FORMAT"` TimeFormat string `mapstructure:"TIME_FORMAT"` } `mapstructure:"WEB"` Swagger struct { Title string `mapstructure:"TITLE"` Version string `mapstructure:"VERSION"` Host string `mapstructure:"HOST"` BaseURL string `mapstructure:"BASE_URL"` Description string `mapstructure:"DESCRIPTION"` Enable bool `mapstructure:"ENABLE"` } `mapstructure:"SWAGGER"` JWT struct { AccessSecretKey string `mapstructure:"ACCESS_SECRET_KEY"` RefreshSecretKey string `mapstructure:"REFRESH_SECRET_KEY"` AccessExpireTime time.Duration `mapstructure:"ACCESS_EXPIRE_TIME"` RefreshExpireTime time.Duration `mapstructure:"REFRESH_EXPIRE_TIME"` } `mapstructure:"JWT"` Database struct { RelaySQL DatabaseConfig `mapstructure:"RELAY_SQL"` } `mapstructure:"DATABASE"` HTMLTemplate struct { SystemMaintenance string `mapstructure:"SYSTEM_MAINTENANCE"` } `mapstructure:"HTML_TEMPLATE"` }
func (*Configs) ReadConfigAvailableDescription ¶
ReadConfigAvailableDescription read config available description อ่าน config html ใช้แสดงเมื่อปิดระบบ
func (*Configs) SetConfigAvailableDescription ¶
SetConfigAvailableDescription set config available description สร้าง config html ใช้แสดงเมื่อปิดระบบ
func (*Configs) SetConfigAvailableStatus ¶
SetConfigAvailableStatus set config available status สร้าง config สถานะ ปิด/เปิด ระบบ
type DatabaseConfig ¶
type DatabaseConfig struct { Host string `mapstructure:"HOST"` Port int `mapstructure:"PORT"` Username string `mapstructure:"USERNAME"` Password string `mapstructure:"PASSWORD"` DatabaseName string `mapstructure:"DATABASE_NAME"` DriverName string `mapstructure:"DRIVER_NAME"` Charset string `mapstructure:"CHARSET"` Timeout string `mapstructure:"TIMEOUT"` MaxIdleConns int `mapstructure:"MAX_IDLE_CONNS"` MaxOpenConns int `mapstructure:"MAX_OPEN_CONNS"` MaxLifetime time.Duration `mapstructure:"MAX_LIFE_TIME"` Enable bool `mapstructure:"ENABLE"` }
type Environment ¶
type Environment string
Environment environment
const ( Develop Environment = "develop" Production Environment = "prod" )
func (Environment) Production ¶
func (e Environment) Production() bool
Production check is production
type LocaleDescription ¶
type LocaleDescription struct { EN string `mapstructure:"en"` TH string `mapstructure:"th"` Locale Language `mapstructure:"success"` }
LocaleDescription locale description
func (LocaleDescription) MarshalJSON ¶
func (ld LocaleDescription) MarshalJSON() ([]byte, error)
MarshalJSON marshall json
func (*LocaleDescription) UnmarshalJSON ¶
func (ld *LocaleDescription) UnmarshalJSON(data []byte) error
UnmarshalJSON unmarshal json
type Result ¶
type Result struct { Code int `json:"code" mapstructure:"code"` Description LocaleDescription `json:"message" mapstructure:"localization"` }
Result result
func (Result) HTTPStatusCode ¶
HTTPStatusCode http status code
type ReturnResult ¶
type ReturnResult struct { JSONDuplicateOrInvalidFormat Result `mapstructure:"json_duplicate_or_invalid_format"` InvalidToken Result `mapstructure:"invalid_token"` InvalidPermissionRole Result `mapstructure:"invalid_permission_role"` TokenNotFound Result `mapstructure:"token_not_found"` UserNotFound Result `mapstructure:"user_not_found"` EmployeeNotFound Result `mapstructure:"employee_not_found"` Internal struct { Success Result `mapstructure:"success"` General Result `mapstructure:"general"` BadRequest Result `mapstructure:"bad_request"` ConnectionError Result `mapstructure:"connection_error"` DatabaseNotFound Result `mapstructure:"database_not_found"` Unauthorized Result `mapstructure:"unauthorized"` Forbidden Result `mapstructure:"forbidden"` TooManyRequests Result `mapstructure:"too_many_requests"` } `mapstructure:"internal"` }
ReturnResult return result model
func (*ReturnResult) CustomMessage ¶
func (rr *ReturnResult) CustomMessage(messageEN, messageTH string, code ...int) *Result
CustomMessage custom message
type SwaggerInfoResult ¶
SwaggerInfoResult swagger info result
type UserPassConfig ¶
Click to show internal directories.
Click to hide internal directories.