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"`
}
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 interface{} `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.
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.
Click to show internal directories.
Click to hide internal directories.