Hobby-RPC is a request-response protocol over HTTP messages.
Clients send JSON in the POST request's body and receive JSON in the response. They can call nullary and unary functions.
To call a nullary function, a client should pass a function name(as the fn
property).
For example, to call a function named SomeNullaryFunction
with curl
:
curl -H "Content-Type: application/json" -X POST -d '{"fn":"SomeNullaryFunction"}' https://some.domain
To call an unary function, a client should pass a function name(as the fn
property) and its input(as the in
property).
For example, to call a function named SomeUnaryFunction
with curl
:
curl -H "Content-Type: application/json" -X POST -d '{"fn":"SomeUnaryFunction","in":42}' https://some.domain
Servers can respond with:
-
Happy path. JSON output in the body.
-
Something is wrong with the request. It could be a malformed JSON, or the Content-Type which doesn't start with 'application/json', or something else.
-
The Authorization header doesn't contain a valid token.
Servers may choose to require clients to be authorized. In such cases, they will forbid any requests except those with valid tokens.
Clients may pass tokens as follows:
curl -H "Content-Type: application/json" -H "Authorization: SomeToken" -X POST -d '{"fn":"SomeNullaryFunction"}' https://some.domain