Documentation ¶
Index ¶
- Constants
- Variables
- func AddCmd(name, comment string, function func())
- func AddShutdownHook(f func())
- func CacheByMemory(key string, seconds int64, maker func() interface{}) interface{}
- func CheckCmd()
- func ClearMemoryCache(key string)
- func DefaultAuthChecker(authLevel int, logger *log.Logger, url *string, in map[string]interface{}, ...) (pass bool, sessionObject interface{})
- func ForForm(in interface{}) interface{}
- func GetCPUMemoryStat() (uint, uint)
- func GetDomainWithScope(request *http.Request, scope string) string
- func GetInject(dataType reflect.Type) interface{}
- func GetServerAddr() string
- func GetSessionId(request *http.Request) string
- func Id10(space string) string
- func Id10L(space string) string
- func Id12(space string) string
- func Id12L(space string) string
- func Id6(space string) string
- func Id6L(space string) string
- func Id8(space string) string
- func Id8L(space string) string
- func IgnoreTplTags(functions template.FuncMap, tags ...string) template.FuncMap
- func Init()
- func IsRunning() bool
- func MakeArgots(argots interface{})
- func MakeDocument() ([]Api, []ArgotInfo)
- func MakeHtmlDocumentFile(title, toFile string) string
- func MakeHtmlDocumentFromFile(title, toFile, fromFile string) string
- func MakeJsonDocument() string
- func MakeJsonDocumentFile(file string)
- func MakeTpl(data interface{}, functions template.FuncMap, text string) string
- func MakeTplOut(writer io.Writer, data interface{}, functions template.FuncMap, text string)
- func MakeUrl(request *http.Request, path string) string
- func NewTimerServer(name string, interval time.Duration, run func(*bool), start func(), ...)
- func Proxy(authLevel int, path string, toApp, toPath string)
- func Publish(channel, data string) bool
- func Register(authLevel int, path string, serviceFunc interface{}, memo string)
- func RegisterSimpleWebsocket(authLevel int, path string, onOpen interface{}, memo string)
- func RegisterSimpleWebsocketWithOptions(authLevel int, path string, onOpen interface{}, memo string, ...)
- func RegisterWithOptions(authLevel int, path string, serviceFunc interface{}, memo string, ...)
- func ResetAllSets()
- func ResponseStatic(filePath string, request *http.Request, response *Response) (int, error)
- func Restful(authLevel int, method, path string, serviceFunc interface{}, memo string)
- func RestfulWithOptions(authLevel int, method, path string, serviceFunc interface{}, memo string, ...)
- func Rewrite(path string, toPath string)
- func SetActionAuthChecker(...)
- func SetAuthChecker(...)
- func SetAuthFailedData(data interface{})
- func SetChecker(ck func(request *http.Request) bool)
- func SetClientKeys(deviceIdKey, clientAppKey, sessionIdKey string)
- func SetErrorHandle(...)
- func SetInFilter(...)
- func SetInject(data interface{})
- func SetInjectFunc(factory func() interface{})
- func SetOutFilter(...)
- func SetProxyBy(...)
- func SetRewriteBy(by func(request *Request) (toPath string, rewrite bool))
- func SetSessionId(request *http.Request, sessionId string)
- func SetSessionIdMaker(maker func() string)
- func SetUserId(request *http.Request, userId string)
- func SetVersion(serverVersion string)
- func SetWorkPath(p string)
- func Start()
- func StartMemoryCacheCleaner()
- func Static(path, rootPath string)
- func StaticByHost(path, rootPath, host string)
- func Subscribe(channel string, reset func(), received func([]byte)) bool
- func Tpl(data interface{}, functions template.FuncMap, files ...string) string
- func TplOut(writer io.Writer, data interface{}, functions template.FuncMap, ...)
- func UniqueId() string
- func UniqueId14() string
- func UniqueId16() string
- func UniqueId20() string
- func Unregister(method, path string)
- type ActionRegister
- type Api
- type Argot
- type ArgotInfo
- type Arr
- type AsyncServer
- func (as *AsyncServer) Delete(path string, data interface{}, headers ...string) *httpclient.Result
- func (as *AsyncServer) Do(method, path string, data interface{}, headers ...string) *httpclient.Result
- func (as *AsyncServer) Get(path string, headers ...string) *httpclient.Result
- func (as *AsyncServer) Head(path string, headers ...string) *httpclient.Result
- func (as *AsyncServer) ManualDo(method, path string, data interface{}, headers ...string) *httpclient.Result
- func (as *AsyncServer) NewClient(timeout time.Duration) *Client
- func (as *AsyncServer) OnStop(f func())
- func (as *AsyncServer) Post(path string, data interface{}, headers ...string) *httpclient.Result
- func (as *AsyncServer) Put(path string, data interface{}, headers ...string) *httpclient.Result
- func (as *AsyncServer) SetGlobalHeader(k, v string)
- func (as *AsyncServer) Start()
- func (as *AsyncServer) Stop()
- func (as *AsyncServer) Wait()
- type CertSet
- type Client
- func (c *Client) Delete(path string, data interface{}, headers ...string) *httpclient.Result
- func (c *Client) Do(method, path string, data interface{}, headers ...string) *httpclient.Result
- func (c *Client) Get(path string, headers ...string) *httpclient.Result
- func (c *Client) Head(path string, headers ...string) *httpclient.Result
- func (c *Client) Post(path string, data interface{}, headers ...string) *httpclient.Result
- func (c *Client) Put(path string, data interface{}, headers ...string) *httpclient.Result
- type CodeResult
- type Context
- type Counter
- type GzipResponseWriter
- type HostRegister
- func (host *HostRegister) Register(authLevel int, path string, serviceFunc interface{}, memo string)
- func (host *HostRegister) RegisterSimpleWebsocket(authLevel int, path string, onOpen interface{}, memo string)
- func (host *HostRegister) RegisterSimpleWebsocketWithOptions(authLevel int, path string, onOpen interface{}, memo string, ...)
- func (host *HostRegister) RegisterWebsocket(authLevel int, path string, updater *websocket.Upgrader, onOpen interface{}, ...) *ActionRegister
- func (host *HostRegister) RegisterWebsocketWithOptions(authLevel int, path string, updater *websocket.Upgrader, onOpen interface{}, ...) *ActionRegister
- func (host *HostRegister) RegisterWithOptions(authLevel int, path string, serviceFunc interface{}, memo string)
- func (host *HostRegister) Restful(authLevel int, method, path string, serviceFunc interface{}, memo string)
- func (host *HostRegister) RestfulWithOptions(authLevel int, method, path string, serviceFunc interface{}, memo string)
- func (host *HostRegister) Static(path, rootPath string)
- func (host *HostRegister) Unregister(method, path string)
- type Listen
- type Logger
- type Map
- type Request
- func (request *Request) Get(key string) interface{}
- func (request *Request) GetRealIp() string
- func (request *Request) GetSessionId() string
- func (request *Request) MakeUrl(path string) string
- func (request *Request) ResetPath(path string)
- func (request *Request) Set(key string, value interface{})
- func (request *Request) SetSessionId(sessionId string)
- func (request *Request) SetUserId(userId string)
- type Response
- func (response *Response) DontLog200()
- func (response *Response) DontLogArg(arg string)
- func (response *Response) DownloadFile(contentType, filename string, data interface{})
- func (response *Response) Flush()
- func (response *Response) FlushString(s string) (int, error)
- func (response *Response) Header() http.Header
- func (response *Response) Location(location string)
- func (response *Response) SendFile(contentType, filename string)
- func (response *Response) Write(bytes []byte) (int, error)
- func (response *Response) WriteHeader(code int)
- func (response *Response) WriteString(s string) (int, error)
- type Result
- type StartCmd
- type Testing
- type TimeCounter
- type TimeStatistician
- type UploadFile
- type UserAgent
- type WebServiceOptions
Constants ¶
View Source
const ( ResponseCodeHeartbeatPidError = 591 ResponseCodeServiceNotRunning = 592 ResponseCodeHeartbeatFailed = 593 )
View Source
const ResponseCodeHeartbeatSucceed = 299
View Source
const (
ResponseCodePanicError = iota + 580
)
Variables ¶
View Source
var Config = serviceConfig{}
Functions ¶
func AddShutdownHook ¶ added in v1.5.9
func AddShutdownHook(f func())
func CacheByMemory ¶ added in v1.5.20
func ClearMemoryCache ¶ added in v1.5.21
func ClearMemoryCache(key string)
func DefaultAuthChecker ¶ added in v1.3.29
func DefaultAuthChecker(authLevel int, logger *log.Logger, url *string, in map[string]interface{}, request *Request, response *Response, options *WebServiceOptions) (pass bool, sessionObject interface{})
noinspection GoUnusedParameter
func GetCPUMemoryStat ¶ added in v1.5.40
func GetDomainWithScope ¶ added in v1.5.40
func GetServerAddr ¶
func GetServerAddr() string
func IgnoreTplTags ¶ added in v1.5.30
func MakeArgots ¶ added in v1.5.2
func MakeArgots(argots interface{})
func MakeHtmlDocumentFile ¶
生成文档并存储到 html 文件中,使用默认html模版
func MakeHtmlDocumentFromFile ¶
生成文档并存储到 html 文件中,使用指定html模版
func MakeJsonDocumentFile ¶
func MakeJsonDocumentFile(file string)
func MakeTplOut ¶ added in v1.5.42
func NewTimerServer ¶ added in v1.3.17
func RegisterSimpleWebsocket ¶ added in v1.3.29
注册Websocket服务
func RegisterSimpleWebsocketWithOptions ¶ added in v1.5.33
func RegisterSimpleWebsocketWithOptions(authLevel int, path string, onOpen interface{}, memo string, options WebServiceOptions)
func RegisterWithOptions ¶ added in v1.5.33
func RegisterWithOptions(authLevel int, path string, serviceFunc interface{}, memo string, options WebServiceOptions)
注册服务
func ResetAllSets ¶
func ResetAllSets()
func ResponseStatic ¶ added in v1.4.1
func RestfulWithOptions ¶ added in v1.5.33
func RestfulWithOptions(authLevel int, method, path string, serviceFunc interface{}, memo string, options WebServiceOptions)
注册服务
func SetActionAuthChecker ¶
func SetAuthChecker ¶
func SetAuthFailedData ¶ added in v1.3.15
func SetAuthFailedData(data interface{})
func SetChecker ¶
func SetClientKeys ¶ added in v1.4.6
func SetClientKeys(deviceIdKey, clientAppKey, sessionIdKey string)
func SetErrorHandle ¶
func SetInFilter ¶
func SetInFilter(filter func(in *map[string]interface{}, request *Request, response *Response, logger *log.Logger) (out interface{}))
设置前置过滤器
func SetInjectFunc ¶ added in v1.3.10
func SetInjectFunc(factory func() interface{})
func SetOutFilter ¶
func SetOutFilter(filter func(in map[string]interface{}, request *Request, response *Response, out interface{}, logger *log.Logger) (newOut interface{}, isOver bool))
设置后置过滤器
func SetProxyBy ¶
func SetProxyBy(by func(request *Request) (authLevel int, toApp, toPath *string, headers map[string]string))
跳转
func SetRewriteBy ¶
跳转 func SetRewriteBy(by func(request *http.Request) (toPath string, httpVersion int, headers *map[string]string, rewrite bool)) {
func SetSessionId ¶ added in v1.5.33
func SetSessionIdMaker ¶ added in v1.5.49
func SetSessionIdMaker(maker func() string)
func SetVersion ¶ added in v1.5.46
func SetVersion(serverVersion string)
func SetWorkPath ¶ added in v1.6.0
func SetWorkPath(p string)
func StartMemoryCacheCleaner ¶ added in v1.5.20
func StartMemoryCacheCleaner()
func StaticByHost ¶ added in v1.5.49
func StaticByHost(path, rootPath, host string)
func UniqueId14 ¶ added in v1.5.30
func UniqueId14() string
func UniqueId16 ¶ added in v1.5.30
func UniqueId16() string
func UniqueId20 ¶ added in v1.5.30
func UniqueId20() string
Types ¶
type ActionRegister ¶
type ActionRegister struct {
// contains filtered or unexported fields
}
func RegisterWebsocket ¶
func RegisterWebsocketWithOptions ¶ added in v1.5.33
func RegisterWebsocketWithOptions(authLevel int, path string, updater *websocket.Upgrader, onOpen interface{}, onClose interface{}, decoder func(data interface{}) (action string, request map[string]interface{}, err error), encoder func(action string, data interface{}) interface{}, isSimple bool, memo string, options WebServiceOptions) *ActionRegister
注册Websocket服务
func (*ActionRegister) RegisterAction ¶
func (ar *ActionRegister) RegisterAction(authLevel int, actionName string, action interface{}, memo string)
func (*ActionRegister) RegisterActionWithPriority ¶
func (ar *ActionRegister) RegisterActionWithPriority(authLevel, priority int, actionName string, action interface{}, memo string)
type AsyncServer ¶
type AsyncServer struct { Addr string Proto string ProtoName string // contains filtered or unexported fields }
func AsyncStart ¶
func AsyncStart() *AsyncServer
func (*AsyncServer) Delete ¶
func (as *AsyncServer) Delete(path string, data interface{}, headers ...string) *httpclient.Result
func (*AsyncServer) Do ¶
func (as *AsyncServer) Do(method, path string, data interface{}, headers ...string) *httpclient.Result
func (*AsyncServer) Get ¶
func (as *AsyncServer) Get(path string, headers ...string) *httpclient.Result
func (*AsyncServer) Head ¶
func (as *AsyncServer) Head(path string, headers ...string) *httpclient.Result
func (*AsyncServer) ManualDo ¶ added in v1.6.11
func (as *AsyncServer) ManualDo(method, path string, data interface{}, headers ...string) *httpclient.Result
func (*AsyncServer) NewClient ¶ added in v1.5.47
func (as *AsyncServer) NewClient(timeout time.Duration) *Client
func (*AsyncServer) OnStop ¶ added in v1.5.50
func (as *AsyncServer) OnStop(f func())
func (*AsyncServer) Post ¶
func (as *AsyncServer) Post(path string, data interface{}, headers ...string) *httpclient.Result
func (*AsyncServer) Put ¶
func (as *AsyncServer) Put(path string, data interface{}, headers ...string) *httpclient.Result
func (*AsyncServer) SetGlobalHeader ¶
func (as *AsyncServer) SetGlobalHeader(k, v string)
func (*AsyncServer) Start ¶ added in v1.3.33
func (as *AsyncServer) Start()
func (*AsyncServer) Stop ¶
func (as *AsyncServer) Stop()
func (*AsyncServer) Wait ¶ added in v1.3.33
func (as *AsyncServer) Wait()
type Client ¶ added in v1.5.47
type Client struct {
// contains filtered or unexported fields
}
func (*Client) Delete ¶ added in v1.5.47
func (c *Client) Delete(path string, data interface{}, headers ...string) *httpclient.Result
func (*Client) Do ¶ added in v1.5.47
func (c *Client) Do(method, path string, data interface{}, headers ...string) *httpclient.Result
func (*Client) Get ¶ added in v1.5.47
func (c *Client) Get(path string, headers ...string) *httpclient.Result
func (*Client) Head ¶ added in v1.5.47
func (c *Client) Head(path string, headers ...string) *httpclient.Result
type CodeResult ¶ added in v1.3.15
func (*CodeResult) Failed ¶ added in v1.5.33
func (r *CodeResult) Failed(code int, message string)
func (*CodeResult) OK ¶ added in v1.4.5
func (r *CodeResult) OK()
type Counter ¶ added in v1.5.40
type Counter struct { StartTime time.Time EndTime time.Time Total float64 Times uint Failed uint Min float64 Max float64 Avg float64 }
func NewCounter ¶ added in v1.5.40
func NewCounter() *Counter
type GzipResponseWriter ¶
type GzipResponseWriter struct { *Response // contains filtered or unexported fields }
=================================================================================
func NewGzipResponseWriter ¶
func NewGzipResponseWriter(w *Response) *GzipResponseWriter
func (*GzipResponseWriter) Close ¶
func (gzw *GzipResponseWriter) Close()
type HostRegister ¶ added in v1.3.33
type HostRegister struct {
// contains filtered or unexported fields
}
func Host ¶ added in v1.3.33
func Host(host string) HostRegister
func (*HostRegister) Register ¶ added in v1.3.33
func (host *HostRegister) Register(authLevel int, path string, serviceFunc interface{}, memo string)
func (*HostRegister) RegisterSimpleWebsocket ¶ added in v1.3.33
func (host *HostRegister) RegisterSimpleWebsocket(authLevel int, path string, onOpen interface{}, memo string)
func (*HostRegister) RegisterSimpleWebsocketWithOptions ¶ added in v1.5.33
func (host *HostRegister) RegisterSimpleWebsocketWithOptions(authLevel int, path string, onOpen interface{}, memo string, options WebServiceOptions)
func (*HostRegister) RegisterWebsocket ¶ added in v1.3.33
func (host *HostRegister) RegisterWebsocket(authLevel int, path string, updater *websocket.Upgrader, onOpen interface{}, onClose interface{}, decoder func(data interface{}) (action string, request map[string]interface{}, err error), encoder func(action string, data interface{}) interface{}, memo string) *ActionRegister
func (*HostRegister) RegisterWebsocketWithOptions ¶ added in v1.5.33
func (host *HostRegister) RegisterWebsocketWithOptions(authLevel int, path string, updater *websocket.Upgrader, onOpen interface{}, onClose interface{}, decoder func(data interface{}) (action string, request map[string]interface{}, err error), encoder func(action string, data interface{}) interface{}, isSimple bool, memo string, options WebServiceOptions) *ActionRegister
func (*HostRegister) RegisterWithOptions ¶ added in v1.5.33
func (host *HostRegister) RegisterWithOptions(authLevel int, path string, serviceFunc interface{}, memo string)
func (*HostRegister) Restful ¶ added in v1.3.33
func (host *HostRegister) Restful(authLevel int, method, path string, serviceFunc interface{}, memo string)
func (*HostRegister) RestfulWithOptions ¶ added in v1.5.33
func (host *HostRegister) RestfulWithOptions(authLevel int, method, path string, serviceFunc interface{}, memo string)
func (*HostRegister) Static ¶ added in v1.5.49
func (host *HostRegister) Static(path, rootPath string)
func (*HostRegister) Unregister ¶ added in v1.5.40
func (host *HostRegister) Unregister(method, path string)
type Request ¶ added in v1.5.50
func (*Request) GetSessionId ¶ added in v1.5.50
func (*Request) SetSessionId ¶ added in v1.5.50
type Response ¶
type Response struct { Writer http.ResponseWriter ProxyHeader *http.Header // contains filtered or unexported fields }
func (*Response) DontLog200 ¶ added in v1.5.8
func (response *Response) DontLog200()
func (*Response) DontLogArg ¶ added in v1.5.49
func (*Response) DownloadFile ¶ added in v1.5.30
func (*Response) FlushString ¶ added in v1.2.12
func (*Response) WriteHeader ¶
type TimeCounter ¶ added in v1.4.6
type TimeCounter struct {
// contains filtered or unexported fields
}
func StartTimeCounter ¶ added in v1.4.6
func StartTimeCounter() *TimeCounter
func (*TimeCounter) Add ¶ added in v1.4.6
func (t *TimeCounter) Add(name string) float64
func (*TimeCounter) Print ¶ added in v1.4.6
func (t *TimeCounter) Print()
func (*TimeCounter) Sprint ¶ added in v1.4.6
func (t *TimeCounter) Sprint() string
func (*TimeCounter) Total ¶ added in v1.4.6
func (t *TimeCounter) Total() float64
type TimeStatistician ¶ added in v1.4.6
type TimeStatistician struct {
// contains filtered or unexported fields
}
func NewTimeStatistic ¶ added in v1.4.6
func NewTimeStatistic(logger *log.Logger) *TimeStatistician
func (*TimeStatistician) Log ¶ added in v1.4.6
func (t *TimeStatistician) Log()
func (*TimeStatistician) Push ¶ added in v1.4.6
func (t *TimeStatistician) Push(c *TimeCounter) string
type UploadFile ¶ added in v1.5.23
type UploadFile struct { Filename string Header textproto.MIMEHeader Size int64 // contains filtered or unexported fields }
func (*UploadFile) Content ¶ added in v1.5.23
func (uploadFile *UploadFile) Content() ([]byte, error)
func (*UploadFile) Open ¶ added in v1.5.23
func (uploadFile *UploadFile) Open() (multipart.File, error)
func (*UploadFile) Save ¶ added in v1.5.23
func (uploadFile *UploadFile) Save(filename string) error
Source Files ¶
Click to show internal directories.
Click to hide internal directories.