Documentation
¶
Overview ¶
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Package web is a lightweight web framework for Go. It's ideal for writing simple, performant backend web services.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Index ¶
- Constants
- Variables
- func Close()
- func Debug(v ...interface{})
- func Debugf(format string, v ...interface{})
- func Delete(route string, handler interface{})
- func Error(v ...interface{})
- func Errorf(format string, v ...interface{})
- func Fatal(v ...interface{})
- func Fatalf(format string, v ...interface{})
- func Fatalln(v ...interface{})
- func Flags() int
- func Get(route string, handler interface{})
- func GetOutputLevel() int
- func Handler(route string, method string, httpHandler http.Handler)
- func Info(v ...interface{})
- func Infof(format string, v ...interface{})
- func Match(method string, route string, handler interface{})
- func Md5(str, salt string) string
- func MiddlewareDuo(handler interface{})
- func MiddlewareTcp(handler interface{})
- func NewCookie(name string, value string, age int64) *http.Cookie
- func Panic(v ...interface{})
- func Panicf(format string, v ...interface{})
- func Panicln(v ...interface{})
- func Post(route string, handler interface{})
- func Prefix() string
- func Print(v ...interface{})
- func Printf(format string, v ...interface{})
- func Println(v ...interface{})
- func Process(c http.ResponseWriter, req *http.Request)
- func Put(route string, handler interface{})
- func Rand(n int, letters []rune) string
- func RandNum(n int) string
- func RandStr(n int) string
- func Run(addr string)
- func RunDuo(addr string)
- func RunTLS(addr string, config *tls.Config)
- func RunTcp(addr string)
- func SetFlags(flag int)
- func SetOutput(w io.Writer)
- func SetOutputLevel(lvl int)
- func SetPrefix(prefix string)
- func Slug(s string, sep string) string
- func Stack(v ...interface{})
- func UUID() string
- func Urlencode(data map[string]string) string
- func Via(route string, handler interface{})
- func ViaDuo(route string, handler interface{})
- func ViaTcp(route string, handler interface{})
- func Warn(v ...interface{})
- func Warnf(format string, v ...interface{})
- type Config
- type Context
- func (ctx *Context) Abort(status int, body string)
- func (ctx *Context) ClientIp() (string, error)
- func (ctx *Context) ContentType(val string) string
- func (ctx *Context) Forbidden()
- func (ctx *Context) GetBasicAuth() (string, string, error)
- func (ctx *Context) GetCookieSig(key string, val []byte, timestamp string) string
- func (ctx *Context) GetSecureCookie(name string) (string, bool)
- func (ctx *Context) NotFound(message string)
- func (ctx *Context) NotModified()
- func (ctx *Context) SetCookie(cookie *http.Cookie)
- func (ctx *Context) SetHeader(hdr string, val string, unique bool)
- func (ctx *Context) SetSecureCookie(name string, val string, age int64)
- func (ctx *Context) Unauthorized()
- func (ctx *Context) WriteJSON(code, msg string, data ...interface{})
- func (ctx *Context) WriteString(content string)
- func (ctx *Context) WriteXml(content string)
- type Duo
- func (t *Duo) Fd(conn *net.TCPConn) string
- func (t *Duo) Middleware(handler interface{})
- func (t *Duo) Pack(w io.Writer, data []byte) error
- func (t *Duo) Pipe(conn *net.TCPConn)
- func (t *Duo) Run(addr string)
- func (t *Duo) Unpack(r io.Reader) ([]byte, error)
- func (t *Duo) Via(route string, handler interface{})
- func (t *Duo) Write(conn *net.TCPConn, code byte, data ...[]byte)
- type DuoContext
- type Json
- func (j *Json) Array() ([]interface{}, error)
- func (j *Json) Bool() (bool, error)
- func (j *Json) Bytes() ([]byte, error)
- func (j *Json) CheckGet(key string) (*Json, bool)
- func (j *Json) Del(key string)
- func (j *Json) Encode() ([]byte, error)
- func (j *Json) EncodePretty() ([]byte, error)
- func (j *Json) Float64() (float64, error)
- func (j *Json) Get(key string) *Json
- func (j *Json) GetIndex(index int) *Json
- func (j *Json) GetPath(branch ...string) *Json
- func (j *Json) Int() (int, error)
- func (j *Json) Int64() (int64, error)
- func (j *Json) Interface() interface{}
- func (j *Json) Load(body []byte) (*Json, error)
- func (j *Json) Map() (map[string]interface{}, error)
- func (j *Json) MarshalJSON() ([]byte, error)
- func (j *Json) MustArray(args ...[]interface{}) []interface{}
- func (j *Json) MustBool(args ...bool) bool
- func (j *Json) MustFloat64(args ...float64) float64
- func (j *Json) MustInt(args ...int) int
- func (j *Json) MustInt64(args ...int64) int64
- func (j *Json) MustMap(args ...map[string]interface{}) map[string]interface{}
- func (j *Json) MustString(args ...string) string
- func (j *Json) MustStringArray(args ...[]string) []string
- func (j *Json) MustUint64(args ...uint64) uint64
- func (j *Json) Set(key string, val interface{})
- func (j *Json) SetPath(branch []string, val interface{})
- func (j *Json) String() (string, error)
- func (j *Json) StringArray() ([]string, error)
- func (j *Json) Uint64() (uint64, error)
- func (j *Json) UnmarshalJSON(p []byte) error
- type Logger
- func (l *Logger) Debug(v ...interface{})
- func (l *Logger) Debugf(format string, v ...interface{})
- func (l *Logger) Error(v ...interface{})
- func (l *Logger) Errorf(format string, v ...interface{})
- func (l *Logger) Fatal(v ...interface{})
- func (l *Logger) Fatalf(format string, v ...interface{})
- func (l *Logger) Fatalln(v ...interface{})
- func (l *Logger) Flags() int
- func (l *Logger) Info(v ...interface{})
- func (l *Logger) Infof(format string, v ...interface{})
- func (l *Logger) Output(reqId string, lvl int, calldepth int, s string) error
- func (l *Logger) Panic(v ...interface{})
- func (l *Logger) Panicf(format string, v ...interface{})
- func (l *Logger) Panicln(v ...interface{})
- func (l *Logger) Prefix() string
- func (l *Logger) Print(v ...interface{})
- func (l *Logger) Printf(format string, v ...interface{})
- func (l *Logger) Println(v ...interface{})
- func (l *Logger) SetFlags(flag int)
- func (l *Logger) SetOutputLevel(lvl int)
- func (l *Logger) SetPrefix(prefix string)
- func (l *Logger) Stack(v ...interface{})
- func (l *Logger) Stat() (stats []int64)
- func (l *Logger) Warn(v ...interface{})
- func (l *Logger) Warnf(format string, v ...interface{})
- type MongoDB
- type Mysql
- func (mysql *Mysql) Begin()
- func (mysql *Mysql) Close()
- func (mysql *Mysql) Commit() error
- func (mysql *Mysql) Exec(table, dml string, args ...interface{}) (interface{}, error)
- func (mysql *Mysql) Open(dsn string)
- func (mysql *Mysql) Ping() error
- func (mysql *Mysql) Query(args ...interface{}) ([]interface{}, error)
- func (mysql *Mysql) Rollback() error
- func (mysql *Mysql) Row(args ...interface{}) (interface{}, error)
- type Nsq
- type NsqMessage
- type Redis
- func (r *Redis) Bool(cmd string, args ...interface{}) (bool, error)
- func (r *Redis) Do(cmd string, args ...interface{}) (interface{}, error)
- func (r *Redis) Int64(cmd string, args ...interface{}) (int64, error)
- func (r *Redis) Pool(server string, pwd ...interface{})
- func (r *Redis) String(cmd string, args ...interface{}) (string, error)
- func (r *Redis) StringMap(cmd string, args ...interface{}) (map[string]string, error)
- func (r *Redis) Strings(cmd string, args ...interface{}) ([]string, error)
- type Route
- type Routes
- type Server
- func (s *Server) Close()
- func (s *Server) Delete(route string, handler interface{})
- func (s *Server) Get(route string, handler interface{})
- func (s *Server) Handler(route string, method string, handler http.Handler)
- func (s *Server) Match(method string, route string, handler interface{})
- func (s *Server) Post(route string, handler interface{})
- func (s *Server) Process(c http.ResponseWriter, req *http.Request)
- func (s *Server) Put(route string, handler interface{})
- func (s *Server) Run(addr string)
- func (s *Server) RunTLS(addr string, config *tls.Config) error
- func (s *Server) ServeHTTP(c http.ResponseWriter, req *http.Request)
- func (s *Server) SetLogger(logger *log.Logger)
- type Tcp
- func (t *Tcp) Fd(conn *net.TCPConn) string
- func (t *Tcp) Middleware(handler interface{})
- func (t *Tcp) Pack(w io.Writer, data []byte) error
- func (t *Tcp) Pipe(conn *net.TCPConn)
- func (t *Tcp) Run(addr string)
- func (t *Tcp) Unpack(r io.Reader) ([]byte, error)
- func (t *Tcp) Via(route string, handler interface{})
- func (t *Tcp) WriteJSON(conn *net.TCPConn, code, msg string, data ...interface{})
- type TcpContext
- type Xml
Constants ¶
const ( DuoHead = 0xEF DuoSec = 0x01 DuoMaxContent = 2 << 10 )
const ( // Bits or'ed together to control what's printed. There is no control over the // order they appear (the order listed here) or the format they present (as // described in the comments). A colon appears after these items: // 2009/0123 01:23:23.123123 /a/b/c/d.go:23: message Ldate = 1 << iota // the date: 2009/0123 Ltime // the time: 01:23:23 Lmicroseconds // microsecond resolution: 01:23:23.123123. assumes Ltime. Llongfile // full file name and line number: /a/b/c/d.go:23 Lshortfile // final file name element and line number: d.go:23. overrides Llongfile Lmodule // module name Llevel // level: 0(Debug), 1(Info), 2(Warn), 3(Error), 4(Panic), 5(Fatal) LstdFlags = Ldate | Ltime // initial values for the standard logger Ldefault = Lmodule | Llevel | Lshortfile | LstdFlags )
These flags define which text to prefix to each log entry generated by the Logger.
const ( Ldebug = iota Linfo Lwarn Lerror Lpanic Lfatal )
const ( TcpHead = 0xAA TcpTail = 0x0A TcpMaxContent = 2 << 10 )
const VERSION = "0.0.1"
Variables ¶
var Std = New(os.Stderr, "", Ldefault)
Functions ¶
func Delete ¶
func Delete(route string, handler interface{})
Delete adds a handler for the 'DELETE' http method in the main server.
func Fatal ¶
func Fatal(v ...interface{})
Fatal is equivalent to Print() followed by a call to os.Exit(1).
func Fatalf ¶
func Fatalf(format string, v ...interface{})
Fatalf is equivalent to Printf() followed by a call to os.Exit(1).
func Fatalln ¶
func Fatalln(v ...interface{})
Fatalln is equivalent to Println() followed by a call to os.Exit(1).
func Get ¶
func Get(route string, handler interface{})
Get adds a handler for the 'GET' http method in the main server.
func GetOutputLevel ¶
func GetOutputLevel() int
func Handler ¶
Adds a custom handler. Only for webserver mode. Will have no effect when running as FCGI or SCGI.
func NewCookie ¶
NewCookie is a helper method that returns a new http.Cookie object. Duration is specified in seconds. If the duration is zero, the cookie is permanent. This can be used in conjunction with ctx.SetCookie.
func Panic ¶
func Panic(v ...interface{})
Panic is equivalent to Print() followed by a call to panic().
func Panicf ¶
func Panicf(format string, v ...interface{})
Panicf is equivalent to Printf() followed by a call to panic().
func Panicln ¶
func Panicln(v ...interface{})
Panicln is equivalent to Println() followed by a call to panic().
func Post ¶
func Post(route string, handler interface{})
Post adds a handler for the 'POST' http method in the main server.
func Print ¶
func Print(v ...interface{})
Print calls Output to print to the standard logger. Arguments are handled in the manner of fmt.Print.
func Printf ¶
func Printf(format string, v ...interface{})
Printf calls Output to print to the standard logger. Arguments are handled in the manner of fmt.Printf.
func Println ¶
func Println(v ...interface{})
Println calls Output to print to the standard logger. Arguments are handled in the manner of fmt.Println.
func Process ¶
func Process(c http.ResponseWriter, req *http.Request)
Process invokes the main server's routing system.
func Put ¶
func Put(route string, handler interface{})
Put adds a handler for the 'PUT' http method in the main server.
func Run ¶
func Run(addr string)
Run starts the web application and serves HTTP requests for the main server.
func RunDuo ¶
func RunDuo(addr string)
------------- Run starts the web application and serves Tcp service for the main server.
func RunTcp ¶
func RunTcp(addr string)
Run starts the web application and serves Tcp service for the main server.
func SetOutputLevel ¶
func SetOutputLevel(lvl int)
func SetPrefix ¶
func SetPrefix(prefix string)
SetPrefix sets the output prefix for the standard logger.
func Slug ¶
Slug is a helper function that returns the URL slug for string s. It's used to return clean, URL-friendly strings that can be used in routing.
func Urlencode ¶
Urlencode is a helper method that converts a map into URL-encoded form data. It is a useful when constructing HTTP POST requests.
func Via ¶
func Via(route string, handler interface{})
Post adds a handler for the 'POST' http method in the main server.
func ViaDuo ¶
func ViaDuo(route string, handler interface{})
Add a handler for tcp method in the main server.
Types ¶
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Usage:
import "github.com/api4me/next" conf := next.Config{}
type Context ¶
type Context struct { Request *http.Request Params map[string]string Server *Server http.ResponseWriter }
A Context object is created for every incoming HTTP request, and is passed to handlers as an optional first argument. It provides information about the request, including the http.Request object, the GET and POST params, and acts as a Writer for the response.
func (*Context) Abort ¶
Abort is a helper method that sends an HTTP header and an optional body. It is useful for returning 4xx or 5xx errors. Once it has been called, any return value from the handler will not be written to the response.
func (*Context) ContentType ¶
ContentType sets the Content-Type header for an HTTP response. For example, ctx.ContentType("json") sets the content-type to "application/json" If the supplied value contains a slash (/) it is set as the Content-Type verbatim. The return value is the content type as it was set, or an empty string if none was found.
func (*Context) GetBasicAuth ¶
GetBasicAuth is a helper method of *Context that returns the decoded user and password from the *Context's authorization header
func (*Context) GetCookieSig ¶
func (*Context) NotModified ¶
func (ctx *Context) NotModified()
Notmodified writes a 304 HTTP response
func (*Context) SetHeader ¶
SetHeader sets a response header. If `unique` is true, the current value of that header will be overwritten . If false, it will be appended.
func (*Context) SetSecureCookie ¶
func (*Context) Unauthorized ¶
func (ctx *Context) Unauthorized()
Unauthorized writes a 401 HTTP response
func (*Context) WriteString ¶
WriteString writes string data into the response object.
type Duo ¶
type Duo struct { Conn map[string]*net.TCPConn Config *Config Logger *log.Logger // contains filtered or unexported fields }
func (*Duo) Middleware ¶
func (t *Duo) Middleware(handler interface{})
Post adds a handler for the 'Via' TCP method for tcp.
func (*Duo) Pack ¶
Pack is a utility function to read from the supplied Writer according to the Next protocol spec:
EF01[x][x][x][x][x][x][x][x][x] | | (binary) | |1-byte | 1-byte --------------------------- head size data crc
func (*Duo) Unpack ¶
Unpack is a utility function to read from the supplied Reader according to the Next protocol spec:
EF01[x][x][x][x][x][x][x][x][x] | | (binary) | |1-byte | 1-byte --------------------------- head size data crc
type DuoContext ¶
type DuoContext struct { Method byte Params []byte Duo *Duo Fd string // contains filtered or unexported fields }
-------- Duo Context --------
func (*DuoContext) Write ¶
func (ctx *DuoContext) Write(out []byte)
Writes data into the response object.
type Json ¶
type Json struct {
// contains filtered or unexported fields
}
func (*Json) CheckGet ¶
CheckGet returns a pointer to a new `Json` object and a `bool` identifying success or failure
useful for chained operations when success is important:
if data, ok := js.Get("top_level").CheckGet("inner"); ok { log.Println(data) }
func (*Json) EncodePretty ¶
EncodePretty returns its marshaled data as `[]byte` with indentation
func (*Json) Get ¶
Get returns a pointer to a new `Json` object for `key` in its `map` representation
useful for chaining operations (to traverse a nested JSON):
js.Get("top_level").Get("dict").Get("value").Int()
func (*Json) GetIndex ¶
GetIndex returns a pointer to a new `Json` object for `index` in its `array` representation
this is the analog to Get when accessing elements of a json array instead of a json object:
js.Get("top_level").Get("array").GetIndex(1).Get("key").Int()
func (*Json) GetPath ¶
GetPath searches for the item as specified by the branch without the need to deep dive using Get()'s.
js.GetPath("top_level", "dict")
func (*Json) Interface ¶
func (j *Json) Interface() interface{}
Interface returns the underlying data
func (*Json) MarshalJSON ¶
Implements the json.Marshaler interface.
func (*Json) MustArray ¶
func (j *Json) MustArray(args ...[]interface{}) []interface{}
MustArray guarantees the return of a `[]interface{}` (with optional default)
useful when you want to interate over array values in a succinct manner:
for i, v := range js.Get("results").MustArray() { fmt.Println(i, v) }
func (*Json) MustBool ¶
MustBool guarantees the return of a `bool` (with optional default)
useful when you explicitly want a `bool` in a single value return context:
myFunc(js.Get("param1").MustBool(), js.Get("optional_param").MustBool(true))
func (*Json) MustFloat64 ¶
MustFloat64 guarantees the return of a `float64` (with optional default)
useful when you explicitly want a `float64` in a single value return context:
myFunc(js.Get("param1").MustFloat64(), js.Get("optional_param").MustFloat64(5.150))
func (*Json) MustInt ¶
MustInt guarantees the return of an `int` (with optional default)
useful when you explicitly want an `int` in a single value return context:
myFunc(js.Get("param1").MustInt(), js.Get("optional_param").MustInt(5150))
func (*Json) MustInt64 ¶
MustInt64 guarantees the return of an `int64` (with optional default)
useful when you explicitly want an `int64` in a single value return context:
myFunc(js.Get("param1").MustInt64(), js.Get("optional_param").MustInt64(5150))
func (*Json) MustMap ¶
MustMap guarantees the return of a `map[string]interface{}` (with optional default)
useful when you want to interate over map values in a succinct manner:
for k, v := range js.Get("dictionary").MustMap() { fmt.Println(k, v) }
func (*Json) MustString ¶
MustString guarantees the return of a `string` (with optional default)
useful when you explicitly want a `string` in a single value return context:
myFunc(js.Get("param1").MustString(), js.Get("optional_param").MustString("my_default"))
func (*Json) MustStringArray ¶
MustStringArray guarantees the return of a `[]string` (with optional default)
useful when you want to interate over array values in a succinct manner:
for i, s := range js.Get("results").MustStringArray() { fmt.Println(i, s) }
func (*Json) MustUint64 ¶
MustUInt64 guarantees the return of an `uint64` (with optional default)
useful when you explicitly want an `uint64` in a single value return context:
myFunc(js.Get("param1").MustUint64(), js.Get("optional_param").MustUint64(5150))
func (*Json) Set ¶
Set modifies `Json` map by `key` and `value` Useful for changing single key/value in a `Json` object easily.
func (*Json) SetPath ¶
SetPath modifies `Json`, recursively checking/creating map keys for the supplied path, and then finally writing in the value
func (*Json) StringArray ¶
StringArray type asserts to an `array` of `string`
func (*Json) UnmarshalJSON ¶
Implements the json.Unmarshaler interface.
type Logger ¶
type Logger struct { Level int // contains filtered or unexported fields }
A Logger represents an active logging object that generates lines of output to an io.Writer. Each logging operation makes a single call to the Writer's Write method. A Logger can be used simultaneously from multiple goroutines; it guarantees to serialize access to the Writer.
func New ¶
New creates a new Logger. The out variable sets the destination to which log data will be written. The prefix appears at the beginning of each generated log line. The flag argument defines the logging properties.
func (*Logger) Fatalln ¶
func (l *Logger) Fatalln(v ...interface{})
Fatalln is equivalent to l.Println() followed by a call to os.Exit(1).
func (*Logger) Output ¶
Output writes the output for a logging event. The string s contains the text to print after the prefix specified by the flags of the Logger. A newline is appended if the last character of s is not already a newline. Calldepth is used to recover the PC and is provided for generality, although at the moment on all pre-defined paths it will be 2.
func (*Logger) Panic ¶
func (l *Logger) Panic(v ...interface{})
Panic is equivalent to l.Print() followed by a call to panic().
func (*Logger) Panicln ¶
func (l *Logger) Panicln(v ...interface{})
Panicln is equivalent to l.Println() followed by a call to panic().
func (*Logger) Print ¶
func (l *Logger) Print(v ...interface{})
Print calls l.Output to print to the logger. Arguments are handled in the manner of fmt.Print.
func (*Logger) Printf ¶
Printf calls l.Output to print to the logger. Arguments are handled in the manner of fmt.Printf.
func (*Logger) Println ¶
func (l *Logger) Println(v ...interface{})
Println calls l.Output to print to the logger. Arguments are handled in the manner of fmt.Println.
func (*Logger) SetOutputLevel ¶
SetOutputLevel sets the output level for the logger.
type MongoDB ¶
type MongoDB struct {
// contains filtered or unexported fields
}
func NewMongoDB ¶
func NewMongoDB() *MongoDB
func (*MongoDB) InsertOrUpdate ¶
type Mysql ¶
type NsqMessage ¶
type NsqMessage struct {
*nsq.Message
}
type Redis ¶
type Redis struct {
// contains filtered or unexported fields
}
type Server ¶
type Server struct { Config *Config Logger *log.Logger Env map[string]interface{} // contains filtered or unexported fields }
func (*Server) Handler ¶
Adds a custom handler. Only for webserver mode. Will have no effect when running as FCGI or SCGI.
func (*Server) Process ¶
func (s *Server) Process(c http.ResponseWriter, req *http.Request)
Process invokes the routing system for server s
type Tcp ¶
type Tcp struct { Conn map[string]*net.TCPConn Config *Config Logger *log.Logger // contains filtered or unexported fields }
func (*Tcp) Middleware ¶
func (t *Tcp) Middleware(handler interface{})
Post adds a handler for the 'Via' TCP method for tcp.
func (*Tcp) Pack ¶
Pack is a utility function to read from the supplied Writer according to the Next protocol spec:
AA[x][x][x][x][x][x][x][x]55 | (int32) || (binary) | 4-byte || N-byte ------------------------... size data
func (*Tcp) Unpack ¶
Unpack is a utility function to read from the supplied Reader according to the Next protocol spec:
AA[x][x][x][x][x][x][x][x]55 | (int32) || (binary) | 4-byte || N-byte ------------------------... size data
type TcpContext ¶
type TcpContext struct { Method string Params map[string]string Tcp *Tcp Fd string // contains filtered or unexported fields }
-------- Tcp Context --------
func (*TcpContext) WriteJSON ¶
func (ctx *TcpContext) WriteJSON(code, msg string, data ...interface{})
WriteJSON writes json data into the response object.
type Xml ¶
type Xml struct { }
func (*Xml) ToMap ¶
ToMap parses xml reading from xmlReader and returns the first-level sub-node key-value set, if the first-level sub-node contains child nodes, skip it.