Documentation ¶
Overview ¶
Package api describes microservice example's public JSON-RPC 2.0 API.
Index ¶
Constants ¶
View Source
const Name = "RPC"
Name is a net/rpc type name used as a prefix before method names.
Variables ¶
View Source
var ( ErrTryAgainLater = jsonrpc2.NewError(-503, "temporary error") // Safe to resend. ErrTooManyRequests = jsonrpc2.NewError(-429, "too many requests") // Safe to resend (after delay). ErrNotFound = jsonrpc2.NewError(-404, "not found") // Given ID does not exists. ErrForbidden = jsonrpc2.NewError(-403, "forbidden") // Not allowed by permissions. )
All generic errors which may be returned by RPC methods.
View Source
var ErrsCommon = []error{ jsonrpc2x.ErrInvalidParams, jsonrpc2x.ErrInternal, ErrTryAgainLater, ErrTooManyRequests, ErrForbidden, ErrUnauthorized, }
ErrsCommon may be returned by any RPC method.
View Source
var ErrsExtra = map[string][]error{ Name + ".Example": {ErrNotFound}, Name + ".IncExample": nil, }
ErrsExtra list non-common errors which may be returned by concrete RPC method.
Functions ¶
This section is empty.
Types ¶
type Ctx ¶
type Ctx = apix.JSONRPC2Ctx
Ctx must be embedded and tagged `json:"Ctx"` to prevent JSON embedding.
type RPCExampleReq ¶
RPC.Example returns given user's Example.
type RPCExampleResp ¶
type RPCExampleResp = Example
type RPCIncExampleReq ¶
type RPCIncExampleReq struct {
Ctx `json:"Ctx"`
}
RPC.IncExample increments user's Example.
type RPCIncExampleResp ¶
type RPCIncExampleResp struct{}
Click to show internal directories.
Click to hide internal directories.