Skip to content

Example of how to set up a JSON RPC API using Phoenix 1.4

Notifications You must be signed in to change notification settings

vruizext/phoenix1.4-json-rpc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JsonRpcApi

This is an simple example of how to setup a JSON RPC API with Phoenix 1.4.

After checking out the project, you can start your Phoenix server as usual:

  • Install dependencies with mix deps.get
  • Start Phoenix endpoint with mix phx.server

To test the API you have to send a POST request to the /api endpoint, and include in the payload a valid JSON RPC request.

POST /api HTTP/1.1
[{"jsonrpc": "2.0", "method": "hello", "params": {"name": "FooBar"}, "id": 1},
{"jsonrpc": "2.0", "method": "bye", "params": {"name": "John Doe"}, "id": 23}]

Yields:

[{"id": 1,"jsonrpc": "2.0", "result": {"hello": "FooBar"}},
{"id": 23,"jsonrpc": "2.0", "result": {"bye": "John Doe"}}]

About

Example of how to set up a JSON RPC API using Phoenix 1.4

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages