util

package
v0.0.0-...-ba06689 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 13, 2017 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultLimit = 20

DefaultLimit elements in page in paged requests

View Source
const MaxLimit = 200

MaxLimit max elements in page in paged requests

Variables

View Source
var AnyLog *log.Logger
View Source
var CompLog *log.Logger
View Source
var CronLog *log.Logger
View Source
var DB *runner.DB
View Source
var GinLog *log.Logger
View Source
var MGO *mgo.Session
View Source
var RecLog *log.Logger

Functions

func Atoi

func Atoi(s string) int

func Atoi64

func Atoi64(s string) (int64, error)

Atoi64 parses int64 from string

func CheckErr

func CheckErr(err error, msg ...interface{})

CheckErr check error is nil and if not panic with message

func CheckMatchesRegexp

func CheckMatchesRegexp(regexpStr string, str string)

func CheckOk

func CheckOk(ok bool, msg ...interface{})

CheckOk check ok

func DownloadUrlToFile

func DownloadUrlToFile(url, path string) (data []byte, err error)

func DownloadUrlToFileIfNotExists

func DownloadUrlToFileIfNotExists(url, path string) (data []byte, err error)

func GetJson

func GetJson(i interface{}) string

func GetPathInt64Param

func GetPathInt64Param(c *gin.Context, key string) int64

GetPathInt64Param returns path param with key

func GetUrlContent

func GetUrlContent(url string) (body []byte, err error)

func InitDb

func InitDb(config Config) *runner.DB

func InitEnvironment

func InitEnvironment()

Устанавливает переменные окружения, заданные в local.env

func InitLogs

func InitLogs(c Config)

func InitPersistence

func InitPersistence()

func IsFileExists

func IsFileExists(name string) bool

func ParseForumDate

func ParseForumDate(dateStr string) time.Time

2014-05-18kshdfjkhsdf

func ParseParamsGet

func ParseParamsGet(c *gin.Context, params interface{})

func PrintJson

func PrintJson(i interface{})

func WriteJSONStatus

func WriteJSONStatus(c *gin.Context, model interface{}, httpStatus int)

Types

type AppEnv

type AppEnv struct {
	JsonFilesPath string `envconfig:"HUSTLEDB_APP_JSON_FILES_PATH"`
	LogDirPath    string `envconfig:"HUSTLEDB_APP_LOG_DIR_PATH"`
}

type Config

type Config interface {
	Db() *DbEnv
	App() *AppEnv
}

Config interface

func ReadConfig

func ReadConfig() Config

ReadConfig read config from environment

type DbEnv

type DbEnv struct {
	URL          string `envconfig:"HUSTLEDB_DB_URL"`
	MaxIdleConns int    `envconfig:"HUSTLEDB_DB_MAX_IDLE_CONNS" default:"4"`
	MaxOpenConns int    `envconfig:"HUSTLEDB_DB_MAX_OPEN_CONNS" default:"16"`
	StrictMode   bool   `envconfig:"HUSTLEDB_DB_STRICT_MODE" default:"false"`
	MongoURL     string `envconfig:"HUSTLEDB_MONGO_URL"`
}

DbEnv db settings

type ListDancerParams

type ListDancerParams struct {
	Offset int    `json:"offset" form:"offset"`
	Limit  int    `json:"limit" form:"limit"`
	Query  string `form:"query"`
}

func (*ListDancerParams) Fix

func (pp *ListDancerParams) Fix()

type PageParams

type PageParams struct {
	Offset int `json:"offset" form:"offset"`
	Limit  int `json:"limit" form:"limit"`
}

func (*PageParams) Fix

func (pp *PageParams) Fix()

type PageResponse

type PageResponse struct {
	TotalCount int `json:"totalCount"`
	PageSize   int `json:"pageSize"`
	Count      int `json:"count"`

	Content interface{} `json:"content"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL