Documentation ¶
Index ¶
- Variables
- func AbortWriteHeader(w http.ResponseWriter, code int)
- func BytesToString(b []byte) string
- func CamelString(s string) string
- func PopulateConstructor(value interface{})
- func SnakeString(s string) string
- func StringToBytes(s string) []byte
- type Error
- type ErrorCode
- type ItfConstructor
- type ItfExcludeMethod
- type Option
- type RPCMessage
- type RPCServer
Constants ¶
This section is empty.
Variables ¶
View Source
var SnakeOption = &Option{SnakeNamespace: true}
SnakeOption ...
Functions ¶
func BytesToString ¶
BytesToString convert []byte type to string type.
func CamelString ¶
CamelString converts the accepted string to a camel string (xx_yy to XxYy)
func SnakeString ¶
SnakeString converts the accepted string to a snake string (XxYy to xx_yy)
func StringToBytes ¶
StringToBytes convert string type to []byte type. NOTE: panic if modify the member value of the []byte.
Types ¶
type Error ¶
type Error struct { Code ErrorCode `json:"code"` Message string `json:"message"` Data interface{} `json:"data,omitempty"` }
Error ... Error codes
type ItfExcludeMethod ¶
type ItfExcludeMethod interface{ ExcludeMethod() []string }
ItfExcludeMethod ...
type Option ¶
type Option struct { SnakeNamespace bool BeforeMid []middleInfo }
Option ...
func (*Option) AddBeforeMiddleware ¶
AddBeforeMiddleware ... *
- @Description:
- @receiver o
- @param method
- @param fn: //参数顺序: ctx,method,writer,request
type RPCMessage ¶
type RPCMessage struct { ID json.RawMessage `json:"id,omitempty"` Version string `json:"jsonrpc,omitempty"` Method string `json:"method,omitempty"` Params json.RawMessage `json:"params,omitempty"` Result json.RawMessage `json:"result,omitempty"` Error *Error `json:"error,omitempty"` }
RPCMessage A value of this type can a JSON-RPC request, notification, successful response or error response. Which one it is depends on the fields.
type RPCServer ¶
type RPCServer interface { Opt() *Option Logger() g2util.LevelLogger SetLogger(logger g2util.LevelLogger) ServeHTTP(w http.ResponseWriter, r *http.Request) RegisterForApp(app interface{}) Register(receiver interface{}, names ...string) Handler(ctx context.Context, w http.ResponseWriter, r *http.Request) Stop() }
RPCServer ...
Click to show internal directories.
Click to hide internal directories.