Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // CF -> for use configs model CF = &Configs{} )
View Source
var (
RR = &ReturnResult{}
)
RR -> for use to return result model
Functions ¶
func InitConfig ¶
InitConfig init config
func InitReturnResult ¶
InitReturnResult init return result
Types ¶
type Configs ¶
type Configs struct { UniversalTranslator *ut.UniversalTranslator Validator *validator.Validate App struct { ProjectID string `mapstructure:"project_name"` WebBaseURL string `mapstructure:"web_base_url"` APIBaseURL string `mapstructure:"api_base_url"` Version string `mapstructure:"version"` Release bool `mapstructure:"release"` Port int `mapstructure:"port"` } `mapstructure:"app"` HTTPServer struct { ReadTimeout time.Duration `mapstructure:"read_timeout"` WriteTimeout time.Duration `mapstructure:"write_timeout"` ReadHeaderTimeout time.Duration `mapstructure:"read_header_timeout"` } `mapstructure:"http_server"` Postgresql 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"` } `mapstructure:"postgre_sql"` JWT struct { SecretKey string `mapstructure:"secret_key"` ExpireTime struct { Day time.Duration `mapstructure:"day"` Hour time.Duration `mapstructure:"hour"` Minute time.Duration `mapstructure:"minute"` } `mapstructure:"expire_time"` } `mapstructure:"jwt"` }
Configs models
type Environment ¶
type Environment string
Environment environment
const ( // LOCAL environment local LOCAL Environment = "local" // DEV environment develop DEV Environment = "dev" // PROD environment production PROD Environment = "prod" )
type LocaleDescription ¶
type LocaleDescription struct { EN string `mapstructure:"en"` TH string `mapstructure:"th"` Locale string `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 { InvalidRequest Result `mapstructure:"invalid_request"` InvalidToken Result `mapstructure:"invalid_token"` JSONDuplicateOrInvalidFormat Result `mapstructure:"json_duplicate_or_invalid_format"` Internal struct { Success Result `mapstructure:"success"` BadRequest Result `mapstructure:"bad_request"` ConnectionError Result `mapstructure:"connection_error"` DatabaseNotFound Result `mapstructure:"database_not_found"` Unauthorized Result `mapstructure:"unauthorized"` } `mapstructure:"internal"` }
ReturnResult return result model
func (*ReturnResult) CustomMessage ¶
func (rr *ReturnResult) CustomMessage(messageEN, messageTH string) Result
CustomMessage custom message
func (*ReturnResult) GetLanguage ¶
func (rr *ReturnResult) GetLanguage(r *http.Request) string
GetLanguage get language locale
type SwaggerInfoResult ¶
SwaggerInfoResult swagger info result
type SwaggerStatusResult ¶
type SwaggerStatusResult struct {
Status int `json:"status"`
}
Click to show internal directories.
Click to hide internal directories.