Package api describes microservice example's public JSON-RPC 2.0 API.



    View Source
    const Name = "RPC"

      Name is a net/rpc type name used as a prefix before method names.


      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.
      	ErrUnauthorized    = jsonrpc2.NewError(-401, "unauthorized")      // Missing or invalid Ctx.AccessToken.

        All generic errors which may be returned by RPC methods.

          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.


            This section is empty.


            type Ctx

            type Ctx = apix.JSONRPC2Ctx

              Ctx must be embedded and tagged `json:"Ctx"` to prevent JSON embedding.

              type Example

              type Example struct {
              	Counter   int
              	UpdatedAt time.Time

                Example is an example of user's data.

                type RPCExampleReq

                type RPCExampleReq struct {
                	Ctx      `json:"Ctx"`
                	UserName string

                  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{}