Giter Club home page Giter Club logo

rpcsrv's Introduction

rpcsrv

Introduction

A C++ JSON-RPC server skeleton, in straight C++11.

Currently implements two simple JSON-RPC methods, "ping" (always returns string "pong") and "echo" (echoes params back as the result), but sufficient code exists to support a wide range of RPC methods, inputs and outputs.

Building

Dependencies

rpcsrv requires C++11, libevent 2 and on MACOSX, argp-standalone.

Compiling from source

Building follows the familiar pattern:

git submodule update --init
./autogen.sh	# only if building from git repo
./configure
make
make install

Running the server

Run "./rpcsrvd --help" for a summary of server configuration options, and their default values. See example-config.json for the server JSON configuration file.

Examples

GET / -- Server reflection endpoint

This returns an array of all the JSON-RPC services at this HTTP endpoint.

We only have one service at this endpoint, "myapi":

$ curl http://localhost:12014/
[
  {
    "name": "myapi/1",
    "timestamp": 1550068729,
    "endpoint": "/rpc/1"
  }
]

GET /rpc/1 -- JSON-RPC reflection endpoint

This returns an array of all the JSON-RPC methods for this service.

We have two methods at this service, "ping" and "echo":

$ curl http://localhost:12014/rpc/1
[
  {
    "method": "ping"
  },
  {
    "method": "echo"
  }
]

POST /rpc/1 -- execute RPC calls with JSON-RPC protocol

We call the "echo" RPC, which echoes any parameters sent to it:

$ curl -X POST -d '{"jsonrpc":"2.0","method":"echo","params":[1,2,3,4], "id":1234}' http://localhost:12014/rpc/1
{
  "jsonrpc": "2.0",
  "result": [
    1,
    2,
    3,
    4
  ],
  "id": 1234
}

rpcsrv's People

Contributors

jgarzik avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rpcsrv's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.