Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WriteResponse ¶
func WriteResponse(ctx *fasthttp.RequestCtx, status int, resp ServerResponse)
WriteResponse write response to client with status code and server response struct
Types ¶
type Error ¶
type Error struct { // A Number that indicates the error type that occurred. ErrorHTTPCode int `json:"-"` // A Number that indicates the error type that occurred. ErrorCode int `json:"error_code"` // A String providing a short description of the error. // The message SHOULD be limited to a concise single sentence. ErrorMessage string `json:"error_msg"` // A Primitive or Structured value that contains additional information about the error. Data interface{} `json:"data"` }
Error ... easyjson:json
func (Error) MarshalEasyJSON ¶ added in v0.2.1
MarshalEasyJSON supports easyjson.Marshaler interface
func (Error) MarshalJSON ¶ added in v0.2.1
MarshalJSON supports json.Marshaler interface
func (*Error) UnmarshalEasyJSON ¶ added in v0.2.1
UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (*Error) UnmarshalJSON ¶ added in v0.2.1
UnmarshalJSON supports json.Unmarshaler interface
type Marshaler ¶ added in v0.3.0
Marshaler is the interface implemented by types that can marshal themselves into valid JSON.
type ServerResponse ¶
type ServerResponse struct { // The Object that was returned by the invoked method. This must be null // in case there was an error invoking the method. // As per spec the member will be omitted if there was an error. Response json.RawMessage `json:"response,omitempty"` // An Error object if there was an error invoking the method. It must be // null if there was no error. // As per spec the member will be omitted if there was no error. Error *Error `json:"error,omitempty"` }
ServerResponse represents a JSON-RPC response returned by the server. easyjson:json
func (ServerResponse) MarshalEasyJSON ¶ added in v0.2.1
func (v ServerResponse) MarshalEasyJSON(w *jwriter.Writer)
MarshalEasyJSON supports easyjson.Marshaler interface
func (ServerResponse) MarshalJSON ¶ added in v0.2.1
func (v ServerResponse) MarshalJSON() ([]byte, error)
MarshalJSON supports json.Marshaler interface
func (*ServerResponse) UnmarshalEasyJSON ¶ added in v0.2.1
func (v *ServerResponse) UnmarshalEasyJSON(l *jlexer.Lexer)
UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (*ServerResponse) UnmarshalJSON ¶ added in v0.2.1
func (v *ServerResponse) UnmarshalJSON(data []byte) error
UnmarshalJSON supports json.Unmarshaler interface
type TestArgs ¶ added in v0.2.2
TestArgs args for tests easyjson:json
func (TestArgs) MarshalEasyJSON ¶ added in v0.2.2
MarshalEasyJSON supports easyjson.Marshaler interface
func (TestArgs) MarshalJSON ¶ added in v0.2.2
MarshalJSON supports json.Marshaler interface
func (*TestArgs) UnmarshalEasyJSON ¶ added in v0.2.2
UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (*TestArgs) UnmarshalJSON ¶ added in v0.2.2
UnmarshalJSON supports json.Unmarshaler interface
type TestReply ¶ added in v0.2.2
TestReply reply for tests easyjson:json
func (TestReply) MarshalEasyJSON ¶ added in v0.2.2
MarshalEasyJSON supports easyjson.Marshaler interface
func (TestReply) MarshalJSON ¶ added in v0.2.2
MarshalJSON supports json.Marshaler interface
func (*TestReply) UnmarshalEasyJSON ¶ added in v0.2.2
UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (*TestReply) UnmarshalJSON ¶ added in v0.2.2
UnmarshalJSON supports json.Unmarshaler interface
type Unmarshaler ¶ added in v0.3.0
Unmarshaler is the interface implemented by types that can unmarshal a JSON description of themselves. The input can be assumed to be a valid encoding of a JSON value. UnmarshalJSON must copy the JSON data if it wishes to retain the data after returning.
By convention, to approximate the behavior of Unmarshal itself, Unmarshalers implement UnmarshalJSON([]byte("null")) as a no-op.
type VAPI ¶
type VAPI struct {
// contains filtered or unexported fields
}
VAPI - main structure
func (*VAPI) CallAPI ¶
func (as *VAPI) CallAPI(ctx *fasthttp.RequestCtx, method string)
CallAPI call api method and process it. Modifying body after this function not recommended
func (*VAPI) GetServiceMap ¶
GetServiceMap returns an json api schema todo realize this function
func (*VAPI) RegisterService ¶
RegisterService adds a new service to the api server.
The name parameter is optional: if empty it will be inferred from the receiver type name.
Methods from the receiver will be extracted if these rules are satisfied:
- The receiver is exported (begins with an upper case letter) or local (defined in the package registering the service).
- The method name is exported.
- The method has three arguments: *fasthttp.RequestCtx, *args, *reply.
- All three arguments are pointers.
- The second and third arguments are exported or local.
- The method has return type error.
All other methods are ignored.