Documentation
¶
Overview ¶
Package util includes common utilities.
Index ¶
- Variables
- func Recover()
- func RetGzJSON(w http.ResponseWriter, r *http.Request, res map[string]interface{})
- func RetGzResult(w http.ResponseWriter, r *http.Request, res *Result)
- func RetJSON(w http.ResponseWriter, r *http.Request, res map[string]interface{})
- func RetResult(w http.ResponseWriter, r *http.Request, res *Result)
- type Result
- type WSChannel
- type ZipFile
Constants ¶
This section is empty.
Variables ¶
View Source
var File = myfile{}
File utilities.
View Source
var Go = mygo{}
Go utilities.
View Source
var Net = mynet{}
Network utilities.
View Source
var OS = myos{}
OS utilities.
View Source
var Rand = myrand{}
Random utilities.
View Source
var Str = str{}
String utilities.
View Source
var Zip = myzip{}
Zip utilities.
Functions ¶
func RetGzJSON ¶
func RetGzJSON(w http.ResponseWriter, r *http.Request, res map[string]interface{})
RetGzJSON writes HTTP response with "Content-Type, application/json" and "Content-Encoding, gzip".
func RetGzResult ¶
func RetGzResult(w http.ResponseWriter, r *http.Request, res *Result)
RetGzResult writes HTTP response with "Content-Type, application/json" and "Content-Encoding, gzip".
Types ¶
type Result ¶
type Result struct {
Succ bool `json:"succ"` // successful or not
Code int `json:"code"` // return code
Msg string `json:"msg"` // message
Data interface{} `json:"data"` // data object
}
Result.
type WSChannel ¶
type WSChannel struct {
Sid string // wide session id
Conn *websocket.Conn // websocket connection
Request *http.Request // HTTP request related
Time time.Time // the latest use time
}
WSChannel represents a WebSocket channel.
func (*WSChannel) ReadJSON ¶
ReadJSON reads the next JSON-encoded message from the channel and stores it in the value pointed to by v.
type ZipFile ¶
type ZipFile struct {
// contains filtered or unexported fields
}
ZipFile represents a zip file.
func (*ZipFile) AddDirectory ¶
AddDirectory adds a directory.
func (*ZipFile) AddDirectoryN ¶
AddDirectoryN adds directories.
Click to show internal directories.
Click to hide internal directories.