Documentation ¶
Overview ¶
Package ghttp provides powerful http server and simple client implements.
Index ¶
- Constants
- func BuildParams(params interface{}, noUrlEncode ...bool) (encodedParamStr string)
- func ConnectBytes(url string, data ...interface{}) []byte
- func ConnectContent(url string, data ...interface{}) string
- func DeleteBytes(url string, data ...interface{}) []byte
- func DeleteContent(url string, data ...interface{}) string
- func GetBytes(url string, data ...interface{}) []byte
- func GetContent(url string, data ...interface{}) string
- func HeadBytes(url string, data ...interface{}) []byte
- func HeadContent(url string, data ...interface{}) string
- func IsExitError(err interface{}) bool
- func OptionsBytes(url string, data ...interface{}) []byte
- func OptionsContent(url string, data ...interface{}) string
- func PatchBytes(url string, data ...interface{}) []byte
- func PatchContent(url string, data ...interface{}) string
- func PostBytes(url string, data ...interface{}) []byte
- func PostContent(url string, data ...interface{}) string
- func PutBytes(url string, data ...interface{}) []byte
- func PutContent(url string, data ...interface{}) string
- func RequestBytes(method string, url string, data ...interface{}) []byte
- func RequestContent(method string, url string, data ...interface{}) string
- func RestartAllServer(newExeFilePath ...string) error
- func SetGraceful(enabled bool)
- func ShutdownAllServer() error
- func TraceBytes(url string, data ...interface{}) []byte
- func TraceContent(url string, data ...interface{}) string
- func Wait()
- type CORSOptions
- type Client
- func (c *Client) BasicAuth(user, pass string) *Client
- func (c *Client) BrowserMode(enabled bool) *Client
- func (c *Client) Clone() *Client
- func (c *Client) Connect(url string, data ...interface{}) (*ClientResponse, error)
- func (c *Client) ConnectBytes(url string, data ...interface{}) []byte
- func (c *Client) ConnectContent(url string, data ...interface{}) string
- func (c *Client) Delete(url string, data ...interface{}) (*ClientResponse, error)
- func (c *Client) DeleteBytes(url string, data ...interface{}) []byte
- func (c *Client) DeleteContent(url string, data ...interface{}) string
- func (c *Client) DoRequest(method, url string, data ...interface{}) (*ClientResponse, error)
- func (c *Client) Get(url string) (*ClientResponse, error)
- func (c *Client) GetBytes(url string, data ...interface{}) []byte
- func (c *Client) GetContent(url string, data ...interface{}) string
- func (c *Client) Head(url string, data ...interface{}) (*ClientResponse, error)
- func (c *Client) HeadBytes(url string, data ...interface{}) []byte
- func (c *Client) HeadContent(url string, data ...interface{}) string
- func (c *Client) Options(url string, data ...interface{}) (*ClientResponse, error)
- func (c *Client) OptionsBytes(url string, data ...interface{}) []byte
- func (c *Client) OptionsContent(url string, data ...interface{}) string
- func (c *Client) Patch(url string, data ...interface{}) (*ClientResponse, error)
- func (c *Client) PatchBytes(url string, data ...interface{}) []byte
- func (c *Client) PatchContent(url string, data ...interface{}) string
- func (c *Client) Post(url string, data ...interface{}) (resp *ClientResponse, err error)
- func (c *Client) PostBytes(url string, data ...interface{}) []byte
- func (c *Client) PostContent(url string, data ...interface{}) string
- func (c *Client) Put(url string, data ...interface{}) (*ClientResponse, error)
- func (c *Client) PutBytes(url string, data ...interface{}) []byte
- func (c *Client) PutContent(url string, data ...interface{}) string
- func (c *Client) RequestBytes(method string, url string, data ...interface{}) []byte
- func (c *Client) RequestContent(method string, url string, data ...interface{}) string
- func (c *Client) Retry(retryCount int, retryInterval int) *Client
- func (c *Client) SetBasicAuth(user, pass string)
- func (c *Client) SetBrowserMode(enabled bool)
- func (c *Client) SetCookie(key, value string)
- func (c *Client) SetCookieMap(cookieMap map[string]string)
- func (c *Client) SetHeader(key, value string)
- func (c *Client) SetHeaderRaw(header string)
- func (c *Client) SetPrefix(prefix string)
- func (c *Client) SetRetry(retryCount int, retryInterval int)
- func (c *Client) SetTimeOut(t time.Duration)
- func (c *Client) TimeOut(t time.Duration) *Client
- func (c *Client) Trace(url string, data ...interface{}) (*ClientResponse, error)
- func (c *Client) TraceBytes(url string, data ...interface{}) []byte
- func (c *Client) TraceContent(url string, data ...interface{}) string
- type ClientResponse
- func Connect(url string, data ...interface{}) (*ClientResponse, error)
- func Delete(url string, data ...interface{}) (*ClientResponse, error)
- func DoRequest(method, url string, data ...interface{}) (*ClientResponse, error)
- func Get(url string) (*ClientResponse, error)
- func Head(url string, data ...interface{}) (*ClientResponse, error)
- func Options(url string, data ...interface{}) (*ClientResponse, error)
- func Patch(url string, data ...interface{}) (*ClientResponse, error)
- func Post(url string, data ...interface{}) (*ClientResponse, error)
- func Put(url string, data ...interface{}) (*ClientResponse, error)
- func Trace(url string, data ...interface{}) (*ClientResponse, error)
- type Controller
- type Cookie
- func (c *Cookie) Contains(key string) bool
- func (c *Cookie) Get(key string, def ...string) string
- func (c *Cookie) GetSessionId() string
- func (c *Cookie) Map() map[string]string
- func (c *Cookie) Output()
- func (c *Cookie) Remove(key string)
- func (c *Cookie) RemoveCookie(key, domain, path string)
- func (c *Cookie) Set(key, value string)
- func (c *Cookie) SetCookie(key, value, domain, path string, maxAge int64, httpOnly ...bool)
- func (c *Cookie) SetSessionId(id string)
- type CookieItem
- type Domain
- func (d *Domain) AddMiddleware(handlers ...HandlerFunc)
- func (d *Domain) BindController(pattern string, c Controller, methods ...string)
- func (d *Domain) BindControllerMethod(pattern string, c Controller, method string)
- func (d *Domain) BindControllerRest(pattern string, c Controller)
- func (d *Domain) BindHandler(pattern string, handler HandlerFunc)
- func (d *Domain) BindHookHandler(pattern string, hook string, handler HandlerFunc)
- func (d *Domain) BindHookHandlerByMap(pattern string, hookmap map[string]HandlerFunc)
- func (d *Domain) BindMiddleware(pattern string, handlers ...HandlerFunc)
- func (d *Domain) BindObject(pattern string, obj interface{}, methods ...string)
- func (d *Domain) BindObjectMethod(pattern string, obj interface{}, method string)
- func (d *Domain) BindObjectRest(pattern string, obj interface{})
- func (d *Domain) BindStatusHandler(status int, handler HandlerFunc)
- func (d *Domain) BindStatusHandlerByMap(handlerMap map[int]HandlerFunc)
- func (d *Domain) Group(prefix string, groups ...func(g *RouterGroup)) *RouterGroup
- type GroupItem
- type HandlerFunc
- type LogHandler
- type Middleware
- type Request
- func (r *Request) AddPost(key string, value string)
- func (r *Request) AddQuery(key string, value string)
- func (r *Request) AddRouterString(key, value string)
- func (r *Request) BasicAuth(user, pass string, tips ...string) bool
- func (r *Request) Error(value ...interface{})
- func (r *Request) Exit()
- func (r *Request) ExitAll()
- func (r *Request) ExitHook()
- func (r *Request) Get(key string, def ...interface{}) string
- func (r *Request) GetArray(key string, def ...interface{}) []string
- func (r *Request) GetClientIp() string
- func (r *Request) GetFloat32(key string, def ...interface{}) float32
- func (r *Request) GetFloat64(key string, def ...interface{}) float64
- func (r *Request) GetFloats(key string, def ...interface{}) []float64
- func (r *Request) GetHost() string
- func (r *Request) GetInt(key string, def ...interface{}) int
- func (r *Request) GetInterfaces(key string, def ...interface{}) []interface{}
- func (r *Request) GetInts(key string, def ...interface{}) []int
- func (r *Request) GetJson() *gjson.Json
- func (r *Request) GetMap(def ...map[string]string) map[string]string
- func (r *Request) GetParam(key string, def ...interface{}) *gvar.Var
- func (r *Request) GetPost(key string, def ...interface{}) []string
- func (r *Request) GetPostArray(key string, def ...interface{}) []string
- func (r *Request) GetPostBool(key string, def ...interface{}) bool
- func (r *Request) GetPostFloat32(key string, def ...interface{}) float32
- func (r *Request) GetPostFloat64(key string, def ...interface{}) float64
- func (r *Request) GetPostFloats(key string, def ...interface{}) []float64
- func (r *Request) GetPostInt(key string, def ...interface{}) int
- func (r *Request) GetPostInterfaces(key string, def ...interface{}) []interface{}
- func (r *Request) GetPostInts(key string, def ...interface{}) []int
- func (r *Request) GetPostMap(def ...map[string]string) map[string]string
- func (r *Request) GetPostString(key string, def ...interface{}) string
- func (r *Request) GetPostStrings(key string, def ...interface{}) []string
- func (r *Request) GetPostToStruct(pointer interface{}, mapping ...map[string]string) error
- func (r *Request) GetPostUint(key string, def ...interface{}) uint
- func (r *Request) GetPostVar(key string, def ...interface{}) *gvar.Var
- func (r *Request) GetQuery(key string, def ...interface{}) []string
- func (r *Request) GetQueryArray(key string, def ...interface{}) []string
- func (r *Request) GetQueryBool(key string, def ...interface{}) bool
- func (r *Request) GetQueryFloat32(key string, def ...interface{}) float32
- func (r *Request) GetQueryFloat64(key string, def ...interface{}) float64
- func (r *Request) GetQueryFloats(key string, def ...interface{}) []float64
- func (r *Request) GetQueryInt(key string, def ...interface{}) int
- func (r *Request) GetQueryInterfaces(key string, def ...interface{}) []interface{}
- func (r *Request) GetQueryInts(key string, def ...interface{}) []int
- func (r *Request) GetQueryMap(def ...map[string]string) map[string]string
- func (r *Request) GetQueryString(key string, def ...interface{}) string
- func (r *Request) GetQueryStrings(key string, def ...interface{}) []string
- func (r *Request) GetQueryToStruct(pointer interface{}, mapping ...map[string]string) error
- func (r *Request) GetQueryUint(key string, def ...interface{}) uint
- func (r *Request) GetQueryVar(key string, def ...interface{}) *gvar.Var
- func (r *Request) GetRaw() []byte
- func (r *Request) GetRawString() string
- func (r *Request) GetReferer() string
- func (r *Request) GetRequest(key string, def ...interface{}) []string
- func (r *Request) GetRequestArray(key string, def ...interface{}) []string
- func (r *Request) GetRequestBool(key string, def ...interface{}) bool
- func (r *Request) GetRequestFloat32(key string, def ...interface{}) float32
- func (r *Request) GetRequestFloat64(key string, def ...interface{}) float64
- func (r *Request) GetRequestFloats(key string, def ...interface{}) []float64
- func (r *Request) GetRequestInt(key string, def ...interface{}) int
- func (r *Request) GetRequestInterfaces(key string, def ...interface{}) []interface{}
- func (r *Request) GetRequestInts(key string, def ...interface{}) []int
- func (r *Request) GetRequestMap(def ...map[string]string) map[string]string
- func (r *Request) GetRequestString(key string, def ...interface{}) string
- func (r *Request) GetRequestStrings(key string, def ...interface{}) []string
- func (r *Request) GetRequestToStruct(pointer interface{}, mapping ...map[string]string) error
- func (r *Request) GetRequestUint(key string, def ...interface{}) uint
- func (r *Request) GetRequestVar(key string, def ...interface{}) *gvar.Var
- func (r *Request) GetRouterArray(key string) []string
- func (r *Request) GetRouterString(key string) string
- func (r *Request) GetSessionId() string
- func (r *Request) GetString(key string, def ...interface{}) string
- func (r *Request) GetStrings(key string, def ...interface{}) []string
- func (r *Request) GetToStruct(pointer interface{}, mapping ...map[string]string) error
- func (r *Request) GetUint(key string, def ...interface{}) uint
- func (r *Request) GetUrl() string
- func (r *Request) GetVar(key string, def ...interface{}) *gvar.Var
- func (r *Request) IsAjaxRequest() bool
- func (r *Request) IsExited() bool
- func (r *Request) IsFileRequest() bool
- func (r *Request) MakeSessionId() string
- func (r *Request) SetParam(key string, value interface{})
- func (r *Request) SetPost(key string, value string)
- func (r *Request) SetQuery(key string, value string)
- func (r *Request) SetRouterString(key, value string)
- func (r *Request) WebSocket() (*WebSocket, error)
- type Response
- func (r *Response) Buffer() []byte
- func (r *Response) BufferLength() int
- func (r *Response) CORS(options CORSOptions)
- func (r *Response) CORSDefault()
- func (r *Response) ClearBuffer()
- func (r *Response) DefaultCORSOptions() CORSOptions
- func (r *Response) Output()
- func (r *Response) ParseTpl(tpl string, params ...gview.Params) (string, error)
- func (r *Response) ParseTplContent(content string, params ...gview.Params) (string, error)
- func (r *Response) RedirectBack()
- func (r *Response) RedirectTo(location string)
- func (r *Response) ServeFile(path string, allowIndex ...bool)
- func (r *Response) ServeFileDownload(path string, name ...string)
- func (r *Response) SetBuffer(data []byte)
- func (r *Response) Write(content ...interface{})
- func (r *Response) WriteJson(content interface{}) error
- func (r *Response) WriteJsonP(content interface{}) error
- func (r *Response) WriteStatus(status int, content ...interface{})
- func (r *Response) WriteTpl(tpl string, params ...gview.Params) error
- func (r *Response) WriteTplContent(content string, params ...gview.Params) error
- func (r *Response) WriteXml(content interface{}, rootTag ...string) error
- func (r *Response) Writef(format string, params ...interface{})
- func (r *Response) Writefln(format string, params ...interface{})
- func (r *Response) Writeln(content ...interface{})
- type ResponseWriter
- type Router
- type RouterGroup
- func (g *RouterGroup) ALL(pattern string, object interface{}, params ...interface{}) *RouterGroup
- func (g *RouterGroup) Bind(items []GroupItem) *RouterGroup
- func (g *RouterGroup) COMMON(pattern string, object interface{}, params ...interface{}) *RouterGroup
- func (g *RouterGroup) CONNECT(pattern string, object interface{}, params ...interface{}) *RouterGroup
- func (g *RouterGroup) Clone() *RouterGroup
- func (g *RouterGroup) DELETE(pattern string, object interface{}, params ...interface{}) *RouterGroup
- func (g *RouterGroup) GET(pattern string, object interface{}, params ...interface{}) *RouterGroup
- func (g *RouterGroup) Group(prefix string, groups ...func(g *RouterGroup)) *RouterGroup
- func (g *RouterGroup) HEAD(pattern string, object interface{}, params ...interface{}) *RouterGroup
- func (g *RouterGroup) Hook(pattern string, hook string, handler HandlerFunc) *RouterGroup
- func (g *RouterGroup) Middleware(handlers ...HandlerFunc) *RouterGroup
- func (g *RouterGroup) OPTIONS(pattern string, object interface{}, params ...interface{}) *RouterGroup
- func (g *RouterGroup) PATCH(pattern string, object interface{}, params ...interface{}) *RouterGroup
- func (g *RouterGroup) POST(pattern string, object interface{}, params ...interface{}) *RouterGroup
- func (g *RouterGroup) PUT(pattern string, object interface{}, params ...interface{}) *RouterGroup
- func (g *RouterGroup) REST(pattern string, object interface{}) *RouterGroup
- func (g *RouterGroup) TRACE(pattern string, object interface{}, params ...interface{}) *RouterGroup
- type Server
- func (s *Server) AddMiddleware(handlers ...HandlerFunc)
- func (s *Server) AddSearchPath(path string)
- func (s *Server) AddStaticPath(prefix string, path string)
- func (s *Server) BindController(pattern string, c Controller, methods ...string)
- func (s *Server) BindControllerMethod(pattern string, c Controller, method string)
- func (s *Server) BindControllerRest(pattern string, c Controller)
- func (s *Server) BindHandler(pattern string, handler HandlerFunc)
- func (s *Server) BindHookHandler(pattern string, hook string, handler HandlerFunc)
- func (s *Server) BindHookHandlerByMap(pattern string, hookmap map[string]HandlerFunc)
- func (s *Server) BindMiddleware(pattern string, handlers ...HandlerFunc)
- func (s *Server) BindObject(pattern string, obj interface{}, methods ...string)
- func (s *Server) BindObjectMethod(pattern string, obj interface{}, method string)
- func (s *Server) BindObjectRest(pattern string, obj interface{})
- func (s *Server) BindStatusHandler(status int, handler HandlerFunc)
- func (s *Server) BindStatusHandlerByMap(handlerMap map[int]HandlerFunc)
- func (s *Server) Domain(domains string) *Domain
- func (s *Server) DumpRoutesMap()
- func (s *Server) EnableAdmin(pattern ...string)
- func (s *Server) EnableHTTPS(certFile, keyFile string, tlsConfig ...tls.Config)
- func (s *Server) EnablePprof(pattern ...string)
- func (s *Server) GetCookieDomain() string
- func (s *Server) GetCookieMaxAge() int64
- func (s *Server) GetCookiePath() string
- func (s *Server) GetLogHandler() LogHandler
- func (s *Server) GetLogPath() string
- func (s *Server) GetName() string
- func (s *Server) GetRouteMap() string
- func (s *Server) GetSessionIdName() string
- func (s *Server) GetSessionMaxAge() int64
- func (s *Server) GetSessionStoragePath() string
- func (s *Server) Group(prefix string, groups ...func(g *RouterGroup)) *RouterGroup
- func (s *Server) IsAccessLogEnabled() bool
- func (s *Server) IsErrorLogEnabled() bool
- func (s *Server) Run()
- func (s *Server) SetAccessLogEnabled(enabled bool)
- func (s *Server) SetAddr(itemFunc string)
- func (s *Server) SetAllowIps(ips []string)
- func (s *Server) SetConfig(c ServerConfig)
- func (s *Server) SetCookieDomain(domain string)
- func (s *Server) SetCookieMaxAge(age int64)
- func (s *Server) SetCookiePath(path string)
- func (s *Server) SetDenyIps(ips []string)
- func (s *Server) SetDenyRoutes(routes []string)
- func (s *Server) SetDumpRouteMap(enabled bool)
- func (s *Server) SetErrorLogEnabled(enabled bool)
- func (s *Server) SetFileServerEnabled(enabled bool)
- func (s *Server) SetGzipContentTypes(types []string)
- func (s *Server) SetHTTPSAddr(itemFunc string)
- func (s *Server) SetHTTPSPort(port ...int)
- func (s *Server) SetIdleTimeout(t time.Duration)
- func (s *Server) SetIndexFiles(index []string)
- func (s *Server) SetIndexFolder(enabled bool)
- func (s *Server) SetKeepAlive(enabled bool)
- func (s *Server) SetLogHandler(handler LogHandler)
- func (s *Server) SetLogPath(path string)
- func (s *Server) SetLogStdout(enabled bool)
- func (s *Server) SetMaxHeaderBytes(b int)
- func (s *Server) SetNameToUriType(t int)
- func (s *Server) SetPort(port ...int)
- func (s *Server) SetReadTimeout(t time.Duration)
- func (s *Server) SetRewrite(uri string, rewrite string)
- func (s *Server) SetRewriteMap(rewrites map[string]string)
- func (s *Server) SetRouterCacheExpire(expire int)
- func (s *Server) SetServerAgent(agent string)
- func (s *Server) SetServerRoot(root string)
- func (s *Server) SetSessionIdName(name string)
- func (s *Server) SetSessionMaxAge(age int64)
- func (s *Server) SetSessionStoragePath(path string)
- func (s *Server) SetTLSConfig(tlsConfig tls.Config)
- func (s *Server) SetView(view *gview.View)
- func (s *Server) SetWriteTimeout(t time.Duration)
- func (s *Server) Shutdown() error
- func (s *Server) Start() error
- func (s *Server) Status() int
- func (s *Server) UpdateSession(id string, data map[string]interface{})
- type ServerConfig
- type Session
- func (s *Session) Clear()
- func (s *Session) Contains(key string) bool
- func (s *Session) Export() (data []byte, err error)
- func (s *Session) Get(key string, def ...interface{}) interface{}
- func (s *Session) GetBool(key string, def ...interface{}) bool
- func (s *Session) GetBytes(key string, def ...interface{}) []byte
- func (s *Session) GetDuration(key string, def ...interface{}) time.Duration
- func (s *Session) GetFloat32(key string, def ...interface{}) float32
- func (s *Session) GetFloat64(key string, def ...interface{}) float64
- func (s *Session) GetFloats(key string, def ...interface{}) []float64
- func (s *Session) GetGTime(key string, format ...string) *gtime.Time
- func (s *Session) GetInt(key string, def ...interface{}) int
- func (s *Session) GetInt16(key string, def ...interface{}) int16
- func (s *Session) GetInt32(key string, def ...interface{}) int32
- func (s *Session) GetInt64(key string, def ...interface{}) int64
- func (s *Session) GetInt8(key string, def ...interface{}) int8
- func (s *Session) GetInterfaces(key string, def ...interface{}) []interface{}
- func (s *Session) GetInts(key string, def ...interface{}) []int
- func (s *Session) GetMap(key string, tags ...string) map[string]interface{}
- func (s *Session) GetMapDeep(key string, tags ...string) map[string]interface{}
- func (s *Session) GetMaps(key string, tags ...string) []map[string]interface{}
- func (s *Session) GetMapsDeep(key string, tags ...string) []map[string]interface{}
- func (s *Session) GetString(key string, def ...interface{}) string
- func (s *Session) GetStrings(key string, def ...interface{}) []string
- func (s *Session) GetStruct(key string, pointer interface{}, mapping ...map[string]string) error
- func (s *Session) GetStructDeep(key string, pointer interface{}, mapping ...map[string]string) error
- func (s *Session) GetStructs(key string, pointer interface{}, mapping ...map[string]string) error
- func (s *Session) GetStructsDeep(key string, pointer interface{}, mapping ...map[string]string) error
- func (s *Session) GetTime(key string, format ...string) time.Time
- func (s *Session) GetUint(key string, def ...interface{}) uint
- func (s *Session) GetUint16(key string, def ...interface{}) uint16
- func (s *Session) GetUint32(key string, def ...interface{}) uint32
- func (s *Session) GetUint64(key string, def ...interface{}) uint64
- func (s *Session) GetUint8(key string, def ...interface{}) uint8
- func (s *Session) GetVar(key string, def ...interface{}) *gvar.Var
- func (s *Session) Id() string
- func (s *Session) IsDirty() bool
- func (s *Session) Map() map[string]interface{}
- func (s *Session) Remove(key string)
- func (s *Session) Restore(data []byte) (err error)
- func (s *Session) Set(key string, value interface{})
- func (s *Session) Sets(m map[string]interface{})
- func (s *Session) Size() int
- func (s *Session) UpdateExpire()
- type WebSocket
Constants ¶
const ( SERVER_STATUS_STOPPED = 0 // Server状态:停止 SERVER_STATUS_RUNNING = 1 // Server状态:运行 HOOK_BEFORE_SERVE = "HOOK_BEFORE_SERVE" // 回调事件,在执行服务前 HOOK_AFTER_SERVE = "HOOK_AFTER_SERVE" // 回调事件,在执行服务后 HOOK_BEFORE_OUTPUT = "HOOK_BEFORE_OUTPUT" // 回调事件,在输出结果前 HOOK_AFTER_OUTPUT = "HOOK_AFTER_OUTPUT" // 回调事件,在输出结果后 HTTP_METHODS = "GET,PUT,POST,DELETE,PATCH,HEAD,CONNECT,OPTIONS,TRACE" )
const ( NAME_TO_URI_TYPE_DEFAULT = 0 // 服务注册时对象和方法名称转换为URI时,全部转为小写,单词以'-'连接符号连接 NAME_TO_URI_TYPE_FULLNAME = 1 // 不处理名称,以原有名称构建成URI NAME_TO_URI_TYPE_ALLLOWER = 2 // 仅转为小写,单词间不使用连接符号 NAME_TO_URI_TYPE_CAMEL = 3 // 采用驼峰命名方式 )
const ( // TextMessage denotes a text data message. The text message payload is // interpreted as UTF-8 encoded text data. WS_MSG_TEXT = websocket.TextMessage // BinaryMessage denotes a binary data message. WS_MSG_BINARY = websocket.BinaryMessage // CloseMessage denotes a close control message. The optional message // payload contains a numeric code and text. Use the FormatCloseMessage // function to format a close message payload. WS_MSG_CLOSE = websocket.CloseMessage // PingMessage denotes a ping control message. The optional message payload // is UTF-8 encoded text. WS_MSG_PING = websocket.PingMessage // PongMessage denotes a pong control message. The optional message payload // is UTF-8 encoded text. WS_MSG_PONG = websocket.PongMessage )
Variables ¶
This section is empty.
Functions ¶
func BuildParams ¶
构建请求参数,参数支持任意数据类型,常见参数类型为string/map。 如果参数为map类型,参数值将会进行urlencode编码;可以通过 noUrlEncode:true 参数取消编码。
func ConnectBytes ¶
func ConnectContent ¶
func DeleteBytes ¶
func DeleteContent ¶
func GetContent ¶
func HeadContent ¶
func IsExitError ¶
func IsExitError(err interface{}) bool
主要用于开发者在HTTP处理中自定义异常捕获时,判断捕获的异常是否Server抛出的自定义退出异常
func OptionsBytes ¶
func OptionsContent ¶
func PatchBytes ¶
func PatchContent ¶
func PostContent ¶
func PutContent ¶
func RequestBytes ¶
func RequestContent ¶
func RestartAllServer ¶
重启Web Server,参数支持自定义重启的可执行文件路径,不传递时默认和原有可执行文件路径一致。 针对*niux系统: 平滑重启 针对windows : 完整重启
func TraceBytes ¶
func TraceContent ¶
Types ¶
type CORSOptions ¶
type CORSOptions struct { AllowOrigin string // Access-Control-Allow-Origin AllowCredentials string // Access-Control-Allow-Credentials ExposeHeaders string // Access-Control-Expose-Headers MaxAge int // Access-Control-Max-Age AllowMethods string // Access-Control-Allow-Methods AllowHeaders string // Access-Control-Allow-Headers }
See https://www.w3.org/TR/cors/ . 服务端允许跨域请求选项
type Client ¶
http客户端
func (*Client) BrowserMode ¶
链式操作, See SetBrowserMode
func (*Client) Connect ¶
func (c *Client) Connect(url string, data ...interface{}) (*ClientResponse, error)
func (*Client) ConnectBytes ¶
func (*Client) ConnectContent ¶
func (*Client) Delete ¶
func (c *Client) Delete(url string, data ...interface{}) (*ClientResponse, error)
DELETE请求
func (*Client) DeleteBytes ¶
func (*Client) DeleteContent ¶
func (*Client) DoRequest ¶
func (c *Client) DoRequest(method, url string, data ...interface{}) (*ClientResponse, error)
请求并返回response对象
func (*Client) GetContent ¶
func (*Client) Head ¶
func (c *Client) Head(url string, data ...interface{}) (*ClientResponse, error)
func (*Client) HeadContent ¶
func (*Client) Options ¶
func (c *Client) Options(url string, data ...interface{}) (*ClientResponse, error)
func (*Client) OptionsBytes ¶
func (*Client) OptionsContent ¶
func (*Client) Patch ¶
func (c *Client) Patch(url string, data ...interface{}) (*ClientResponse, error)
func (*Client) PatchBytes ¶
func (*Client) PatchContent ¶
func (*Client) Post ¶
func (c *Client) Post(url string, data ...interface{}) (resp *ClientResponse, err error)
POST请求提交数据,默认使用表单方式提交数据(绝大部分场景下也是如此)。 如果服务端对Content-Type有要求,可使用Client对象进行请求,单独设置相关属性。 支持文件上传,需要字段格式为:FieldName=@file:
func (*Client) PostContent ¶
func (*Client) Put ¶
func (c *Client) Put(url string, data ...interface{}) (*ClientResponse, error)
PUT请求
func (*Client) PutContent ¶
func (*Client) RequestBytes ¶
请求并返回服务端结果(内部会自动读取服务端返回结果并关闭缓冲区指针)
func (*Client) RequestContent ¶
func (*Client) SetBrowserMode ¶
是否模拟浏览器模式(自动保存提交COOKIE)
func (*Client) SetCookieMap ¶
使用Map设置COOKIE
func (*Client) Trace ¶
func (c *Client) Trace(url string, data ...interface{}) (*ClientResponse, error)
func (*Client) TraceBytes ¶
func (*Client) TraceContent ¶
type ClientResponse ¶
客户端请求结果对象
func Connect ¶
func Connect(url string, data ...interface{}) (*ClientResponse, error)
func Delete ¶
func Delete(url string, data ...interface{}) (*ClientResponse, error)
func DoRequest ¶
func DoRequest(method, url string, data ...interface{}) (*ClientResponse, error)
func Get ¶
func Get(url string) (*ClientResponse, error)
func Head ¶
func Head(url string, data ...interface{}) (*ClientResponse, error)
func Options ¶
func Options(url string, data ...interface{}) (*ClientResponse, error)
func Patch ¶
func Patch(url string, data ...interface{}) (*ClientResponse, error)
func Post ¶
func Post(url string, data ...interface{}) (*ClientResponse, error)
func Put ¶
func Put(url string, data ...interface{}) (*ClientResponse, error)
func Trace ¶
func Trace(url string, data ...interface{}) (*ClientResponse, error)
func (*ClientResponse) GetCookie ¶
func (r *ClientResponse) GetCookie(key string) string
获得返回的指定COOKIE值
func (*ClientResponse) ReadAllString ¶
func (r *ClientResponse) ReadAllString() string
获取返回的数据(字符串).
type Cookie ¶
type Cookie struct {
// contains filtered or unexported fields
}
COOKIE对象,非并发安全。
func (*Cookie) RemoveCookie ¶
标记该cookie在对应的域名和路径失效 删除cookie的重点是需要通知浏览器客户端cookie已过期
type Domain ¶
type Domain struct {
// contains filtered or unexported fields
}
域名管理器对象
func (*Domain) AddMiddleware ¶
func (d *Domain) AddMiddleware(handlers ...HandlerFunc)
注册中间件,绑定到全局路由规则("/*")上,中间件参数支持多个。
func (*Domain) BindController ¶
func (d *Domain) BindController(pattern string, c Controller, methods ...string)
控制器注册
func (*Domain) BindControllerMethod ¶
func (d *Domain) BindControllerMethod(pattern string, c Controller, method string)
控制器方法注册,methods参数区分大小写
func (*Domain) BindControllerRest ¶
func (d *Domain) BindControllerRest(pattern string, c Controller)
RESTful控制器注册
func (*Domain) BindHandler ¶
func (d *Domain) BindHandler(pattern string, handler HandlerFunc)
注意该方法是直接绑定方法的内存地址,执行的时候直接执行该方法,不会存在初始化新的控制器逻辑
func (*Domain) BindHookHandler ¶
func (d *Domain) BindHookHandler(pattern string, hook string, handler HandlerFunc)
绑定指定的hook回调函数, hook参数的值由ghttp server设定,参数不区分大小写 目前hook支持:Init/Shut
func (*Domain) BindHookHandlerByMap ¶
func (d *Domain) BindHookHandlerByMap(pattern string, hookmap map[string]HandlerFunc)
通过map批量绑定回调函数
func (*Domain) BindMiddleware ¶
func (d *Domain) BindMiddleware(pattern string, handlers ...HandlerFunc)
注册中间件,绑定到指定的路由规则上,中间件参数支持多个。
func (*Domain) BindObject ¶
执行对象方法
func (*Domain) BindObjectMethod ¶
执行对象方法注册,methods参数不区分大小写
func (*Domain) BindObjectRest ¶
RESTful执行对象注册
func (*Domain) BindStatusHandler ¶
func (d *Domain) BindStatusHandler(status int, handler HandlerFunc)
绑定指定的状态码回调函数
func (*Domain) BindStatusHandlerByMap ¶
func (d *Domain) BindStatusHandlerByMap(handlerMap map[int]HandlerFunc)
通过map批量绑定状态码回调函数
func (*Domain) Group ¶
func (d *Domain) Group(prefix string, groups ...func(g *RouterGroup)) *RouterGroup
获取分组路由对象(绑定域名)
type Request ¶
type Request struct { *http.Request Id int // 请求ID(当前Server对象唯一) Server *Server // 请求关联的服务器对象 Cookie *Cookie // 与当前请求绑定的Cookie对象(并发安全) Session *Session // 与当前请求绑定的Session对象(并发安全) Response *Response // 对应请求的返回数据操作对象 Router *Router // 匹配到的路由对象 EnterTime int64 // 请求进入时间(微秒) LeaveTime int64 // 请求完成时间(微秒) Middleware *Middleware // 中间件功能调用对象 // contains filtered or unexported fields }
请求对象
func (*Request) AddRouterString ¶
func (*Request) ExitHook ¶
func (r *Request) ExitHook()
仅针对HOOK执行,默认情况下HOOK会按照优先级进行调用,当使用ExitHook后当前类型的后续HOOK将不会被调用
func (*Request) GetFloat32 ¶
func (*Request) GetFloat64 ¶
func (*Request) GetInterfaces ¶
func (*Request) GetPostArray ¶
func (*Request) GetPostBool ¶
func (*Request) GetPostFloat32 ¶
func (*Request) GetPostFloat64 ¶
func (*Request) GetPostFloats ¶
func (*Request) GetPostInt ¶
func (*Request) GetPostInterfaces ¶
func (*Request) GetPostInts ¶
func (*Request) GetPostMap ¶
获取指定键名的关联数组,并且给定当指定键名不存在时的默认值 需要注意的是,如果其中一个字段为数组形式,那么只会返回第一个元素,如果需要获取全部的元素,请使用GetPostArray获取特定字段内容
func (*Request) GetPostString ¶
func (*Request) GetPostStrings ¶
func (*Request) GetPostToStruct ¶
将所有的request参数映射到struct属性上,参数object应当为一个struct对象的指针, mapping为非必需参数,自定义参数与属性的映射关系
func (*Request) GetPostUint ¶
func (*Request) GetQueryArray ¶
func (*Request) GetQueryBool ¶
func (*Request) GetQueryFloat32 ¶
func (*Request) GetQueryFloat64 ¶
func (*Request) GetQueryFloats ¶
func (*Request) GetQueryInt ¶
func (*Request) GetQueryInterfaces ¶
func (*Request) GetQueryInts ¶
func (*Request) GetQueryMap ¶
获取指定键名的关联数组,并且给定当指定键名不存在时的默认值
func (*Request) GetQueryString ¶
func (*Request) GetQueryStrings ¶
func (*Request) GetQueryToStruct ¶
将所有的get参数映射到struct属性上,参数object应当为一个struct对象的指针, mapping为非必需参数,自定义参数与属性的映射关系
func (*Request) GetQueryUint ¶
func (*Request) GetQueryVar ¶
func (*Request) GetRequest ¶
获得router、post或者get提交的参数,如果有同名参数,那么按照router->get->post优先级进行覆盖
func (*Request) GetRequestArray ¶
func (*Request) GetRequestBool ¶
func (*Request) GetRequestFloat32 ¶
func (*Request) GetRequestFloat64 ¶
func (*Request) GetRequestFloats ¶
func (*Request) GetRequestInt ¶
func (*Request) GetRequestInterfaces ¶
func (*Request) GetRequestInts ¶
func (*Request) GetRequestMap ¶
获取指定键名的关联数组,并且给定当指定键名不存在时的默认值 需要注意的是,如果其中一个字段为数组形式,那么只会返回第一个元素,如果需要获取全部的元素,请使用GetRequestArray获取特定字段内容
func (*Request) GetRequestString ¶
func (*Request) GetRequestStrings ¶
func (*Request) GetRequestToStruct ¶
将所有的request参数映射到struct属性上,参数object应当为一个struct对象的指针, mapping为非必需参数,自定义参数与属性的映射关系
func (*Request) GetRequestUint ¶
func (*Request) GetRequestVar ¶
func (*Request) GetStrings ¶
func (*Request) GetToStruct ¶
将所有的request参数映射到struct属性上,参数pointer应当为一个struct对象的指针, mapping为非必需参数,自定义参数与属性的映射关系
func (*Request) SetRouterString ¶
type Response ¶
type Response struct { ResponseWriter Server *Server // 所属Web Server Writer *ResponseWriter // ResponseWriter的别名 // contains filtered or unexported fields }
服务端请求返回对象。 注意该对象并没有实现http.ResponseWriter接口,而是依靠ghttp.ResponseWriter实现。
func (*Response) CORS ¶
func (r *Response) CORS(options CORSOptions)
See https://www.w3.org/TR/cors/ . 允许请求跨域访问.
func (*Response) ParseTplContent ¶
解析并返回模板内容
func (*Response) RedirectTo ¶
返回location标识,引导客户端跳转。 注意这里要先把设置的cookie输出,否则会被忽略。
func (*Response) ServeFileDownload ¶
静态文件下载处理
func (*Response) WriteStatus ¶
返回HTTP Code状态码
func (*Response) WriteTplContent ¶
展示模板内容,可以给定模板参数,及临时的自定义模板函数
type ResponseWriter ¶
type ResponseWriter struct { http.ResponseWriter Status int // http status // contains filtered or unexported fields }
自定义的ResponseWriter,用于写入流的控制
func (*ResponseWriter) Write ¶
func (w *ResponseWriter) Write(data []byte) (int, error)
覆盖父级的WriteHeader方法
func (*ResponseWriter) WriteHeader ¶
func (w *ResponseWriter) WriteHeader(status int)
覆盖父级的WriteHeader方法, 这里只会记录Status做缓冲处理, 并不会立即输出到HEADER。
type Router ¶
type Router struct { Uri string // 注册时的pattern - uri Method string // 注册时的pattern - method Domain string // 注册时的pattern - domain RegRule string // 路由规则解析后对应的正则表达式 RegNames []string // 路由规则解析后对应的变量名称数组 Priority int // 优先级,用于链表排序,值越大优先级越高 }
路由对象
type RouterGroup ¶
type RouterGroup struct {
// contains filtered or unexported fields
}
分组路由对象
func (*RouterGroup) ALL ¶
func (g *RouterGroup) ALL(pattern string, object interface{}, params ...interface{}) *RouterGroup
绑定所有的HTTP Method请求方式
func (*RouterGroup) COMMON ¶
func (g *RouterGroup) COMMON(pattern string, object interface{}, params ...interface{}) *RouterGroup
绑定常用方法: GET/PUT/POST/DELETE
func (*RouterGroup) CONNECT ¶
func (g *RouterGroup) CONNECT(pattern string, object interface{}, params ...interface{}) *RouterGroup
func (*RouterGroup) Clone ¶
func (g *RouterGroup) Clone() *RouterGroup
func (*RouterGroup) DELETE ¶
func (g *RouterGroup) DELETE(pattern string, object interface{}, params ...interface{}) *RouterGroup
func (*RouterGroup) GET ¶
func (g *RouterGroup) GET(pattern string, object interface{}, params ...interface{}) *RouterGroup
func (*RouterGroup) Group ¶
func (g *RouterGroup) Group(prefix string, groups ...func(g *RouterGroup)) *RouterGroup
层级递归创建分组路由注册项
func (*RouterGroup) HEAD ¶
func (g *RouterGroup) HEAD(pattern string, object interface{}, params ...interface{}) *RouterGroup
func (*RouterGroup) Hook ¶
func (g *RouterGroup) Hook(pattern string, hook string, handler HandlerFunc) *RouterGroup
func (*RouterGroup) Middleware ¶
func (g *RouterGroup) Middleware(handlers ...HandlerFunc) *RouterGroup
func (*RouterGroup) OPTIONS ¶
func (g *RouterGroup) OPTIONS(pattern string, object interface{}, params ...interface{}) *RouterGroup
func (*RouterGroup) PATCH ¶
func (g *RouterGroup) PATCH(pattern string, object interface{}, params ...interface{}) *RouterGroup
func (*RouterGroup) POST ¶
func (g *RouterGroup) POST(pattern string, object interface{}, params ...interface{}) *RouterGroup
func (*RouterGroup) PUT ¶
func (g *RouterGroup) PUT(pattern string, object interface{}, params ...interface{}) *RouterGroup
func (*RouterGroup) REST ¶
func (g *RouterGroup) REST(pattern string, object interface{}) *RouterGroup
func (*RouterGroup) TRACE ¶
func (g *RouterGroup) TRACE(pattern string, object interface{}, params ...interface{}) *RouterGroup
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server结构体
func GetServer ¶
func GetServer(name ...interface{}) *Server
获取/创建一个默认配置的HTTP Server(默认监听端口是80) 单例模式,请保证name的唯一性
func (*Server) AddMiddleware ¶
func (s *Server) AddMiddleware(handlers ...HandlerFunc)
注册中间件,绑定到全局路由规则("/*")上,中间件参数支持多个。
func (*Server) AddSearchPath ¶
添加静态文件搜索**目录**,必须给定目录的绝对路径
func (*Server) AddStaticPath ¶
添加URI与静态**目录**的映射
func (*Server) BindController ¶
func (s *Server) BindController(pattern string, c Controller, methods ...string)
绑定控制器,控制器需要实现 gmvc.Controller 接口, 这种方式绑定的控制器每一次请求都会初始化一个新的控制器对象进行处理,对应不同的请求会话, 第三个参数methods用以指定需要注册的方法,支持多个方法名称,多个方法以英文“,”号分隔,区分大小写.
func (*Server) BindControllerMethod ¶
func (s *Server) BindControllerMethod(pattern string, c Controller, method string)
绑定路由到指定的方法执行, 第三个参数method仅支持一个方法注册,不支持多个,并且区分大小写。
func (*Server) BindControllerRest ¶
func (s *Server) BindControllerRest(pattern string, c Controller)
绑定控制器(RESTFul),控制器需要实现gmvc.Controller接口 方法会识别HTTP方法,并做REST绑定处理,例如:Post方法会绑定到HTTP POST的方法请求处理,Delete方法会绑定到HTTP DELETE的方法请求处理 因此只会绑定HTTP Method对应的方法,其他方法不会自动注册绑定 这种方式绑定的控制器每一次请求都会初始化一个新的控制器对象进行处理,对应不同的请求会话
func (*Server) BindHandler ¶
func (s *Server) BindHandler(pattern string, handler HandlerFunc)
注意该方法是直接绑定函数的内存地址,执行的时候直接执行该方法,不会存在初始化新的控制器逻辑
func (*Server) BindHookHandler ¶
func (s *Server) BindHookHandler(pattern string, hook string, handler HandlerFunc)
绑定指定的hook回调函数, pattern参数同BindHandler,支持命名路由;hook参数的值由ghttp server设定,参数不区分大小写
func (*Server) BindHookHandlerByMap ¶
func (s *Server) BindHookHandlerByMap(pattern string, hookmap map[string]HandlerFunc)
通过map批量绑定回调函数
func (*Server) BindMiddleware ¶
func (s *Server) BindMiddleware(pattern string, handlers ...HandlerFunc)
注册中间件,绑定到指定的路由规则上,中间件参数支持多个。
func (*Server) BindObject ¶
绑定对象到URI请求处理中,会自动识别方法名称,并附加到对应的URI地址后面 第三个参数methods用以指定需要注册的方法,支持多个方法名称,多个方法以英文“,”号分隔,区分大小写
func (*Server) BindObjectMethod ¶
绑定对象到URI请求处理中,会自动识别方法名称,并附加到对应的URI地址后面, 第三个参数method仅支持一个方法注册,不支持多个,并且区分大小写。
func (*Server) BindObjectRest ¶
绑定对象到URI请求处理中,会自动识别方法名称,并附加到对应的URI地址后面, 需要注意对象方法的定义必须按照 ghttp.HandlerFunc 来定义
func (*Server) BindStatusHandler ¶
func (s *Server) BindStatusHandler(status int, handler HandlerFunc)
绑定指定的状态码回调函数
func (*Server) BindStatusHandlerByMap ¶
func (s *Server) BindStatusHandlerByMap(handlerMap map[int]HandlerFunc)
通过map批量绑定状态码回调函数
func (*Server) EnableHTTPS ¶
开启HTTPS支持,但是必须提供Cert和Key文件,tlsConfig为可选项
func (*Server) GetCookieDomain ¶
获取http server参数 - CookieDomain
func (*Server) GetCookieMaxAge ¶
获取http server参数 - CookieMaxAge
func (*Server) GetSessionIdName ¶
获取http server参数 - SessionIdName
func (*Server) GetSessionMaxAge ¶
获取http server参数 - SessionMaxAge
func (*Server) GetSessionStoragePath ¶
获取http server参数 - SessionStoragePath
func (*Server) Group ¶
func (s *Server) Group(prefix string, groups ...func(g *RouterGroup)) *RouterGroup
获取分组路由对象
func (*Server) SetAccessLogEnabled ¶
设置是否开启access log日志功能
func (*Server) SetAllowIps ¶
func (*Server) SetConfig ¶
func (s *Server) SetConfig(c ServerConfig)
http server setting设置 注意使用该方法进行http server配置时,需要配置所有的配置项,否则没有配置的属性将会默认变量为空
func (*Server) SetCookieDomain ¶
设置http server参数 - CookieDomain
func (*Server) SetCookieMaxAge ¶
设置http server参数 - CookieMaxAge
func (*Server) SetCookiePath ¶
设置http server参数 - CookiePath
func (*Server) SetDenyIps ¶
func (*Server) SetDenyRoutes ¶
func (*Server) SetErrorLogEnabled ¶
设置是否开启error log日志功能
func (*Server) SetFileServerEnabled ¶
是否开启/关闭静态文件服务,当关闭时仅提供动态接口服务,路由性能会得到一定提升
func (*Server) SetGzipContentTypes ¶
func (*Server) SetHTTPSAddr ¶
设置http server参数 - HTTPS Addr
func (*Server) SetHTTPSPort ¶
设置http server参数 - HTTPS Port
func (*Server) SetIdleTimeout ¶
设置http server参数 - IdleTimeout
func (*Server) SetIndexFiles ¶
设置http server参数 - IndexFiles,默认展示文件,如:index.html, index.htm
func (*Server) SetLogPath ¶
设置日志目录,只有在设置了日志目录的情况下才会输出日志到日志文件中。 日志文件路径格式为: 1. 请求日志: access/YYYY-MM-DD.log 2. 错误日志: error/YYYY-MM-DD.log
func (*Server) SetLogStdout ¶
设置日志内容是否输出到终端,默认情况下只有错误日志才会自动输出到终端。 如果需要输出请求日志到终端,默认情况下使用SetAccessLogEnabled方法开启请求日志特性即可。
func (*Server) SetMaxHeaderBytes ¶
设置http server参数 - MaxHeaderBytes
func (*Server) SetReadTimeout ¶
设置http server参数 - ReadTimeout
func (*Server) SetRewriteMap ¶
设置URI重写规则(批量)
func (*Server) SetRouterCacheExpire ¶
设置路由缓存过期时间(秒)
func (*Server) SetServerAgent ¶
设置http server参数 - ServerAgent
func (*Server) SetServerRoot ¶
设置http server参数 - ServerRoot
func (*Server) SetSessionIdName ¶
设置http server参数 - SessionIdName
func (*Server) SetSessionMaxAge ¶
设置http server参数 - SessionMaxAge
func (*Server) SetSessionStoragePath ¶
设置http server参数 - SessionStoragePath
func (*Server) SetWriteTimeout ¶
设置http server参数 - WriteTimeout
func (*Server) UpdateSession ¶
UpdateSession updates the session with custom map.
type ServerConfig ¶
type ServerConfig struct { Addr string // 监听IP和端口,监听本地所有IP使用":端口"(支持多个地址,使用","号分隔) HTTPSAddr string // HTTPS服务监听地址(支持多个地址,使用","号分隔) HTTPSCertPath string // HTTPS证书文件路径 HTTPSKeyPath string // HTTPS签名文件路径 Handler http.Handler // 默认的处理函数 ReadTimeout time.Duration // 读取超时 WriteTimeout time.Duration // 写入超时 IdleTimeout time.Duration // 等待超时 MaxHeaderBytes int // 最大的header长度 TLSConfig tls.Config // HTTPS证书配置 KeepAlive bool // 是否开启长连接 ServerAgent string // Server Agent View *gview.View // 模板引擎对象 Rewrites map[string]string // URI Rewrite重写配置 IndexFiles []string // Static: 默认访问的文件列表 IndexFolder bool // Static: 如果访问目录是否显示目录列表 ServerRoot string // Static: 服务器服务的本地目录根路径(检索优先级比StaticPaths低) SearchPaths []string // Static: 静态文件搜索目录(包含ServerRoot,按照优先级进行排序) StaticPaths []staticPathItem // Static: 静态文件目录映射(按照优先级进行排序) FileServerEnabled bool // Static: 是否允许静态文件服务(通过静态文件服务方法调用自动识别) CookieMaxAge int64 // Cookie: 有效期(秒) CookiePath string // Cookie: 有效Path(注意同时也会影响SessionID) CookieDomain string // Cookie: 有效Domain(注意同时也会影响SessionID) SessionMaxAge int64 // Session: 有效期(秒) SessionIdName string // Session: SessionId SessionStoragePath string // Session: 存储路径 DenyIps []string // Security: 不允许访问的ip列表,支持ip前缀过滤,如: 10 将不允许10开头的ip访问 AllowIps []string // Security: 仅允许访问的ip列表,支持ip前缀过滤,如: 10 将仅允许10开头的ip访问 DenyRoutes []string // Security: 不允许访问的路由规则列表 LogPath string // Logging: 存放日志的目录路径(默认为空,表示不写文件) LogHandler LogHandler // Logging: 日志配置: 自定义日志处理回调方法(默认为空) LogStdout bool // Logging: 是否打印日志到终端(默认开启) ErrorLogEnabled bool // Logging: 是否开启error log(默认开启) AccessLogEnabled bool // Logging: 是否开启access log(默认关闭) NameToUriType int // Mess: 服务注册时对象和方法名称转换为URI时的规则 GzipContentTypes []string // Mess: 允许进行gzip压缩的文件类型 DumpRouteMap bool // Mess: 是否在程序启动时默认打印路由表信息 RouterCacheExpire int // Mess: 路由检索缓存过期时间(秒) }
HTTP Server 设置结构体,静态配置
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
SESSION对象,并发安全
func (*Session) GetDuration ¶
func (*Session) GetFloat32 ¶
func (*Session) GetFloat64 ¶
func (*Session) GetInterfaces ¶
func (*Session) GetMapDeep ¶
func (*Session) GetMapsDeep ¶
func (*Session) GetStrings ¶
func (*Session) GetStructDeep ¶
func (*Session) GetStructs ¶
func (*Session) GetStructsDeep ¶
func (*Session) UpdateExpire ¶
func (s *Session) UpdateExpire()
更新过期时间(如果用在守护进程中长期使用,需要手动调用进行更新,防止超时被清除)
Source Files ¶
- ghttp.go
- ghttp_client_api.go
- ghttp_client_bytes.go
- ghttp_client_config.go
- ghttp_client_content.go
- ghttp_client_request.go
- ghttp_client_response.go
- ghttp_controller.go
- ghttp_func.go
- ghttp_request.go
- ghttp_request_auth.go
- ghttp_request_hook.go
- ghttp_request_log.go
- ghttp_request_middleware.go
- ghttp_request_params.go
- ghttp_request_post.go
- ghttp_request_query.go
- ghttp_request_request.go
- ghttp_request_router.go
- ghttp_response.go
- ghttp_response_cors.go
- ghttp_response_view.go
- ghttp_response_writer.go
- ghttp_server.go
- ghttp_server_admin.go
- ghttp_server_admin_process.go
- ghttp_server_admin_unix.go
- ghttp_server_config.go
- ghttp_server_config_cookie.go
- ghttp_server_config_logger.go
- ghttp_server_config_route.go
- ghttp_server_config_session.go
- ghttp_server_config_static.go
- ghttp_server_cookie.go
- ghttp_server_domain.go
- ghttp_server_graceful.go
- ghttp_server_handler.go
- ghttp_server_log.go
- ghttp_server_pprof.go
- ghttp_server_router.go
- ghttp_server_router_group.go
- ghttp_server_router_hook.go
- ghttp_server_router_middleware.go
- ghttp_server_router_serve.go
- ghttp_server_service_controller.go
- ghttp_server_service_handler.go
- ghttp_server_service_object.go
- ghttp_server_session.go
- ghttp_server_status.go
- ghttp_server_websocket.go