router.h 583 B

12345678910111213141516171819202122
  1. #ifndef HV_JSON_RPC_ROUTER_H_
  2. #define HV_JSON_RPC_ROUTER_H_
  3. #include "cJSON.h"
  4. typedef void (*jsonrpc_handler)(cJSON* jreq, cJSON* jres);
  5. typedef struct {
  6. const char* method;
  7. jsonrpc_handler handler;
  8. } jsonrpc_router;
  9. void error_response(cJSON* jres, int code, const char* message);
  10. void not_found(cJSON* jreq, cJSON* jres);
  11. void bad_request(cJSON* jreq, cJSON* jres);
  12. void calc_add(cJSON* jreq, cJSON* jres);
  13. void calc_sub(cJSON* jreq, cJSON* jres);
  14. void calc_mul(cJSON* jreq, cJSON* jres);
  15. void calc_div(cJSON* jreq, cJSON* jres);
  16. #endif // HV_JSON_RPC_ROUTER_H_