apibox

package
v0.0.0-...-df2cc63 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2017 License: Apache-2.0 Imports: 43 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Agent_prefix  = "Agent."
	Server_prefix = "RPC_Server."
	PathSeparator = string(os.PathSeparator)
	DevNull       = os.DevNull
	OS_MacOS      = "darwin"
	OS_FreeBSD    = "freebsd"
	OS_Linux      = "linux"
	OS_Windows    = "windows"
	Arch_AMD64    = "amd64"
	Arch_386      = "386"
	ChanLen       = 500

	CONNECT = "CONNECT"
	DELETE  = "DELETE"
	GET     = "GET"
	HEAD    = "HEAD"
	OPTIONS = "OPTIONS"
	PATCH   = "PATCH"
	POST    = "POST"
	PUT     = "PUT"
	TRACE   = "TRACE"

	Zip_gZip       = "gzip"
	Zip_Deflate    = "deflate"
	GZip_Mini_Size = 1024

	Log_file_suffix = ".log"
)
View Source
const (
	LevelDebug = iota
	LevelFatal
	LevelError
	LevelWarn
	LevelInfo
)

Variables

View Source
var (
	LogDir   = Get_Project_Dir() + PathSeparator + "log"
	ConfDir  = Get_Project_Dir() + PathSeparator + "conf"
	PidPath  = LogDir + PathSeparator + "apibox.pid"
	MimePath = ConfDir + PathSeparator + "mime.types"
	ConfPath = ConfDir + PathSeparator + "conf.json"
)
View Source
var (
	ABC_Conf, _ = Get_Conf()
)

Functions

func AESDecode

func AESDecode(enmsg, key string) (string, error)

func AESEncode

func AESEncode(msg, key string) (string, error)

func Accept_Encoding

func Accept_Encoding(r *http.Request) string

func Cmmand_Linux

func Cmmand_Linux(c string, args []string) ([]byte, string, error)

func ConvertUTF8

func ConvertUTF8(src []byte) ([]byte, error)

func Daemon

func Daemon(nochdir, noclose int) (int, error)

func DateToStr

func DateToStr(time time.Time) string

func Exists

func Exists(p string) bool

func Format_Date

func Format_Date(time time.Time, format string) string

func GetCharset

func GetCharset(charset string) encoding.Encoding

func Get_Bin_Dir

func Get_Bin_Dir() string

func Get_Bin_Path

func Get_Bin_Path() string

func Get_File_Size

func Get_File_Size(fileSize int64) string

func Get_Project_Dir

func Get_Project_Dir() string

func Gzip_Binary

func Gzip_Binary(b []byte, w http.ResponseWriter, r *http.Request)

func Gzip_File

func Gzip_File(file_path string, w http.ResponseWriter, r *http.Request)

func Gzip_Html

func Gzip_Html(b io.Reader, w http.ResponseWriter, r *http.Request)

func IsDir

func IsDir(p string) bool

func Load_Mime

func Load_Mime(path string) error

func Log_Debug

func Log_Debug(err ...interface{})

func Log_Err

func Log_Err(err ...interface{})

func Log_Fatal

func Log_Fatal(err ...interface{})

func Log_Info

func Log_Info(err ...interface{})

func Log_Warn

func Log_Warn(err ...interface{})

func Log_level

func Log_level() int

func MkdirByFile

func MkdirByFile(file string) error

func Path_Handle

func Path_Handle(path string, pathParams map[string]string) (string, error)

func SetLogger

func SetLogger(l *log.Logger)

func Set_log_level

func Set_log_level(l int)

func Sign_Handle

func Sign_Handle(s string, iden string) string

func ToStr

func ToStr(value interface{}) (s string)

func WritePidFile

func WritePidFile(file, pid string) error

Types

type Conf

type Conf struct {
	Web WS_Conf `json:"web,omitempty" xml:"web,omitempty"`
	DB  DB_Conf `json:"db,omitempty" xml:"db,omitempty"`
}

func Get_Conf

func Get_Conf() (*Conf, error)

type DB_Conf

type DB_Conf struct {
	Url          string `json:"url" xml:"url"`
	MaxOpenConns int    `json:"max_open_conns" xml:"max_open_conns"`
	MaxIdleConns int    `json:"max_idle_conns" xml:"max_idle_conns"`
}

type HttpClient

type HttpClient struct{}

func (*HttpClient) Create

func (h *HttpClient) Create(reqUrl, method, textData string, headerSet, headerParams, queryPatams map[string]string) ([]byte, error)

type MySQL

type MySQL struct {
	Url string
	DB  *sql.DB
}

func (*MySQL) DB_Open

func (d *MySQL) DB_Open() (*MySQL, error)

func (*MySQL) Delete

func (d *MySQL) Delete(s string) (n int64, err error)

func (*MySQL) Exec

func (d *MySQL) Exec(s string, args ...interface{}) (n int64, err error)

func (*MySQL) Query

func (d *MySQL) Query(obj interface{}, s string) ([]interface{}, error)

func (*MySQL) QueryCount

func (d *MySQL) QueryCount(s string) (int, error)

func (*MySQL) QueryOne

func (d *MySQL) QueryOne(obj interface{}, s string) (interface{}, error)

type SQLUtils

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

func NewSQL

func NewSQL() *SQLUtils

func (*SQLUtils) AsName

func (s *SQLUtils) AsName(n string) *SQLUtils

func (*SQLUtils) Delete

func (s *SQLUtils) Delete() string

func (*SQLUtils) Insert

func (s *SQLUtils) Insert() (string, []interface{})

func (*SQLUtils) Limit

func (s *SQLUtils) Limit(index int, num int) *SQLUtils

func (*SQLUtils) OrderBy

func (s *SQLUtils) OrderBy(name string, sort string) *SQLUtils

func (*SQLUtils) QueryAll

func (s *SQLUtils) QueryAll() string

func (*SQLUtils) QueryByConcat

func (s *SQLUtils) QueryByConcat() string

func (*SQLUtils) QueryCount

func (s *SQLUtils) QueryCount() string

func (*SQLUtils) QueryCountByConcat

func (s *SQLUtils) QueryCountByConcat() string

func (*SQLUtils) RegisterStruct

func (s *SQLUtils) RegisterStruct(i interface{}) *SQLUtils

func (*SQLUtils) SetPK

func (s *SQLUtils) SetPK(pk string) *SQLUtils

func (*SQLUtils) Update

func (s *SQLUtils) Update() (string, []interface{})

func (*SQLUtils) WhereAnd

func (s *SQLUtils) WhereAnd(name string, condition string, value string) *SQLUtils

func (*SQLUtils) WhereConcat

func (s *SQLUtils) WhereConcat(value string, field ...string) *SQLUtils

func (*SQLUtils) WhereOr

func (s *SQLUtils) WhereOr(name string, condition string, value string) *SQLUtils

type StringUtils

type StringUtils string

func (StringUtils) Base64Decode

func (s StringUtils) Base64Decode() (string, error)

func (StringUtils) Base64Encode

func (s StringUtils) Base64Encode() string

func (StringUtils) Bool

func (s StringUtils) Bool() (bool, error)

func (*StringUtils) Clear

func (s *StringUtils) Clear()

func (StringUtils) ContainsBool

func (s StringUtils) ContainsBool(sep string) bool

func (StringUtils) ContainsNum

func (s StringUtils) ContainsNum() (bool, error)

func (StringUtils) Exist

func (s StringUtils) Exist() bool

func (StringUtils) Float32

func (s StringUtils) Float32() (float32, error)

func (StringUtils) Float64

func (s StringUtils) Float64() (float64, error)

func (StringUtils) GenerateRandStr32

func (s StringUtils) GenerateRandStr32() string

func (StringUtils) HMAC_SHA1

func (s StringUtils) HMAC_SHA1(key string) string

func (StringUtils) HMAC_SHA256

func (s StringUtils) HMAC_SHA256(key string) string

func (StringUtils) HMAC_SHA512

func (s StringUtils) HMAC_SHA512(key string) string

func (StringUtils) Int

func (s StringUtils) Int() (int, error)

func (StringUtils) Int16

func (s StringUtils) Int16() (int16, error)

func (StringUtils) Int32

func (s StringUtils) Int32() (int32, error)

func (StringUtils) Int64

func (s StringUtils) Int64() (int64, error)

func (StringUtils) Int8

func (s StringUtils) Int8() (int8, error)

func (StringUtils) MD5

func (s StringUtils) MD5() string

func (StringUtils) RegexpSQLSgin

func (s StringUtils) RegexpSQLSgin() (bool, error)

func (StringUtils) RegexpSQLVal

func (s StringUtils) RegexpSQLVal() (bool, error)

func (StringUtils) SHA1

func (s StringUtils) SHA1() string

func (StringUtils) SHA256

func (s StringUtils) SHA256() string

func (StringUtils) SHA512

func (s StringUtils) SHA512() string

func (*StringUtils) Set

func (s *StringUtils) Set(v string)

func (StringUtils) String

func (s StringUtils) String() string

func (StringUtils) ToTitleLower

func (s StringUtils) ToTitleLower() string

func (StringUtils) ToTitleUpper

func (s StringUtils) ToTitleUpper() string

func (StringUtils) UUID

func (s StringUtils) UUID() (string, error)

func (StringUtils) UUID16

func (s StringUtils) UUID16() (string, error)

func (StringUtils) Uint

func (s StringUtils) Uint() (uint, error)

func (StringUtils) Uint16

func (s StringUtils) Uint16() (uint16, error)

func (StringUtils) Uint32

func (s StringUtils) Uint32() (uint32, error)

func (StringUtils) Uint64

func (s StringUtils) Uint64() (uint64, error)

func (StringUtils) Uint8

func (s StringUtils) Uint8() (uint8, error)

type WS_Conf

type WS_Conf struct {
	Addr           string `json:"addr" xml:"addr"`
	TlsAddr        string `json:"tls_addr" xml:"tls_addr"`
	TlsUrl         string `json:"tls_url" xml:"tls_url"`
	SessionTimeOut int    `json:"session_timeout" xml:"session_timeout"`
	StaticDir      string `json:"static_dir" xml:"static_dir"`
	TemplateDir    string `json:"template_dir" xml:"template_dir"`
	TemplateSuffix string `json:"template_suffix" xml:"template_suffix"`
	EnableTLS      bool   `json:"enable_tls" xml:"enable_tls"`
	CorsWhiteList  string `json:"cors_white_list" xml:"cors_white_list"`
	EnableFcgi     bool   `json:"enable_fcgi" xml:"enable_fcgi"`
	TlsCert        string `json:"tls_cert,omitempty" xml:"tls_cert,omitempty"`
	TlsKey         string `json:"tls_key,omitempty" xml:"tls_key,omitempty"`
	Daemon         bool   `json:"daemon,omitempty" xml:"daemon,omitempty"`
}

Jump to

Keyboard shortcuts

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