core

package
v0.0.0-...-999043c Latest Latest
Warning

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

Go to latest
Published: May 30, 2023 License: Apache-2.0 Imports: 22 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DbQuery

func DbQuery(query string, args ...interface{}) []map[string]interface{}

func GetDb

func GetDb() (*gorm.DB, error)

func GetDbAuto

func GetDbAuto() *gorm.DB

func GetDbAutoMigrate

func GetDbAutoMigrate(values ...interface{}) *gorm.DB

func GetGormAuto

func GetGormAuto() *gorm.DB

func GetWebSocket

func GetWebSocket(group string, hand interfaces.WebSocketInterface) *melody.Melody

func GetXormAuto

func GetXormAuto() *xorm.Engine

func SetConfig

func SetConfig(c *Config)

func SetConfigFile

func SetConfigFile(c string)

Types

type Config

type Config struct {
	Port                string          `json:"port"`
	Host                string          `json:"host"`
	CrossDomain         string          `json:"cross_domain"`
	ApiRouter           string          `json:"api_router"`
	StaticRouter        string          `json:"static_router"`
	IsStaticStripPrefix bool            `json:"is_static_strip_prefix"`
	StaticFileSystem    http.FileSystem `json:"static_file_system"`
	PostMaxMemory       int64           `json:"post_max_memory"`
	Db                  ConfigDb        `json:"db"`
	Redis               ConfigRedis     `json:"redis"`
	UpdateDir           string          `json:"update_dir"`
	UpdatePath          string          `json:"update_path"`
}

func GetInstanceConfig

func GetInstanceConfig() *Config

func (*Config) ReadConfig

func (c *Config) ReadConfig(file string)

func (*Config) ReadPrivateConfig

func (c *Config) ReadPrivateConfig(file string)

type ConfigDb

type ConfigDb struct {
	Host        string            `json:"host"`
	Port        string            `json:"port"`
	User        string            `json:"user"`
	Password    string            `json:"password"`
	Name        string            `json:"name"`
	Prefix      string            `json:"prefix"`
	MaxOpenConn int               `json:"max_open_conn"`
	Params      map[string]string `json:"params"`
	Debug       bool              `json:"debug"`
}

type ConfigRedis

type ConfigRedis struct {
	Addr     string `json:"addr"`
	Password string `json:"password"`
	Db       int    `json:"db"`
}

type Controller

type Controller struct {
	Response
	Request Request
}

func (*Controller) ControllerInit

func (c *Controller) ControllerInit(req Request, res Response)

func (*Controller) RequestToStruct

func (c *Controller) RequestToStruct(v interface{}) error

type Request

type Request struct {
	GET           map[string]string
	POST          map[string]string
	REQUEST       map[string]string
	COOKIE        map[string]string
	SESSION       map[string]string
	HEADER        map[string]string
	BODY          string
	FILES         map[string][]*multipart.FileHeader
	FILE          *multipart.FileHeader
	OriginRequest *http.Request
	OriginValues  url.Values
}

func (*Request) SyncCookieData

func (r *Request) SyncCookieData(request *http.Request)

func (*Request) SyncGetData

func (r *Request) SyncGetData(request *http.Request)

func (*Request) SyncHeaderData

func (r *Request) SyncHeaderData(request *http.Request)

func (*Request) SyncPostData

func (r *Request) SyncPostData(request *http.Request, mem int64)

func (*Request) SyncSessionData

func (r *Request) SyncSessionData(session *session.Session)

type Response

type Response struct {
	Session              *session.Session
	IsWebSocket          bool
	OriginResponseWriter http.ResponseWriter
}

func (*Response) CheckErrDisplayByError

func (r *Response) CheckErrDisplayByError(err error, msg ...string)

func (*Response) ClearSession

func (r *Response) ClearSession()

func (*Response) DeleteSession

func (r *Response) DeleteSession(name string)

func (*Response) Display

func (r *Response) Display(data interface{}, msg string, code int)

func (*Response) DisplayByData

func (r *Response) DisplayByData(data interface{})

func (*Response) DisplayByError

func (r *Response) DisplayByError(msg string, code int, data ...string)

func (*Response) DisplayByRaw

func (r *Response) DisplayByRaw(data []byte)

func (*Response) DisplayByString

func (r *Response) DisplayByString(data string)

func (*Response) DisplayBySuccess

func (r *Response) DisplayBySuccess(msg string)

func (*Response) SetCookie

func (r *Response) SetCookie(name string, value string)

func (*Response) SetHeader

func (r *Response) SetHeader(name string, value string)

func (*Response) SetSession

func (r *Response) SetSession(name string, value string)

type ResponseData

type ResponseData struct {
	Code    int         `json:"code"`
	Data    interface{} `json:"data"`
	Message string      `json:"message"`
}

type RouterManage

type RouterManage struct {
	RegisteredData map[string]reflect.Type
}

func GetInstanceRouterManage

func GetInstanceRouterManage() *RouterManage

func (*RouterManage) GetControllerName

func (rm *RouterManage) GetControllerName(name string) string

func (*RouterManage) GetFunName

func (rm *RouterManage) GetFunName(name string) string

func (*RouterManage) GetModuleName

func (rm *RouterManage) GetModuleName(name string) string

func (*RouterManage) Registered

func (rm *RouterManage) Registered(i interface{})

func (*RouterManage) RouterSend

func (rm *RouterManage) RouterSend(urlPath string, request Request, response Response, crossDomain string)

type WebSocket

type WebSocket struct {
	FunName string
	// contains filtered or unexported fields
}

func (*WebSocket) GetMelody

func (that *WebSocket) GetMelody() *melody.Melody

func (*WebSocket) GetWebSocket

func (that *WebSocket) GetWebSocket() *melody.Melody

func (*WebSocket) SetFunName

func (that *WebSocket) SetFunName(funName string)

func (*WebSocket) WebSocketInit

func (that *WebSocket) WebSocketInit(wsx *melody.Melody)

type Xorm

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

func GetXorm

func GetXorm() (*Xorm, error)

func (*Xorm) Ping

func (x *Xorm) Ping() error

Jump to

Keyboard shortcuts

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