0.9.4 • Published 5 years ago

shrpc v0.9.4

Weekly downloads
4
License
ISC
Repository
github
Last release
5 years ago

Simple HTTP RPC (SHRPC) Protocol

SHRPC protocol is proposed to simplify the disadvantages of JSONRPC version 2.0.

Request

Each valid SHRPC request consists of two parts, procedure descriptor and invocation payload.

Procedure Descriptor

Procedure descriptor, which describes the procedure to be invoked, is represented by a network URI.

POST /{namespace}/{cate}/{procedure}?[_id={procedure identifier}]

Invocation Payload

Invocation payload is a json object of which the fields are the arguments to execute the procedure.

{
	"arg1_name":"val1",
	"arg2_name":123
}

Privilege Control

The SHRPC request is a typical http request. Hence, http headers that are used in user privilege control like Authorization and activity tracking such as Cookie header is also accepted by SHRPC.

Request Method

SHRPC should accept both GET and POST methods, where POST method is defined as an invocation with arguments and GET is, in contrast, without arguments.

Response

The SHRPC responds is also constructed by two parts, execution state and response payload. The execution state is represented by http status code, which represents the invocation status of the procedure request. Response payload contains the execution result or detailed error information.

Execution State

The standard http status code for specific conditions are defined in following table.

codecomment
200The procedure is invoked and terminated normally
400There are something wrong with the request payload
401The info is insufficient or invalid to identify the accessor
403The authorization info is correct but without sufficient privilege
404The procedure is not defined
500The procedure cannot be executed or the invocation is terminated unexpectedly due to some server internal faults

Please note that the SHRPC is a standard http request. Hence, other standard http code such as 301, 302, 307, 308, 401 and 403 must be followed as well.

Response Payload

The response payload is a json object contains following fields.

fieldoccurrencedefaultcomment
_idallnullThe value same as _id provided by caller in procedure descriptor
retsuccess@any | undefinedThe result of the invocation. The absence of this field means the function returns nothing
errorerror0The detailed error code used to identify exact error conditions
msgerror""The human readable error message

Reserved and Customizable Error Code Ranges

The following table defines the standard error codes reserved for shrpc.

errordescription
400000Use this if you don't wanna specify the error detail....
400001The provided request payload is not a valid json syntax
400002The arguments provided in the payload is insufficient or invalid to invoke the procedure
401000The information is insufficient to identify the accessor
403000The authorized information has insufficient privilege to invoke the procedure
404000The requested procedure is not available
500000Unexpected internal server error! If you catch this, that means you got problem with your code....
500001The argument verification context provided is invalid

Please note that error codes locate within following interval are reserved for shrpc.

HTTP_STATUS_CODE 100, HTTP_STATUS_CODE 100 + 100

Developers can feel free to define custom error codes within following interval.

( HTTP_STATUS_CODE 100, {HTTP_STATUS_CODE + 1} 100 )

0.9.4

5 years ago

0.9.3

5 years ago

0.9.2

5 years ago

0.9.1

5 years ago

0.9.0

5 years ago

0.3.0

5 years ago

0.2.2

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.17

6 years ago

0.1.16

6 years ago

0.1.15

6 years ago

0.1.14

6 years ago

0.1.13

6 years ago

0.1.12

6 years ago

0.1.11

6 years ago

0.1.10

6 years ago

0.1.9

6 years ago

0.1.8

6 years ago

0.1.7

6 years ago

0.1.6

6 years ago

0.1.5

6 years ago

0.1.4

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago