JSONRPC2 v2.0.0 JSONRPC2.Servers.HTTP.Plug View Source
A plug that responds to POSTed JSON-RPC 2.0 in the request body.
If you wish to start a standalone server which will respond to JSON-RPC 2.0
POSTs at any URL, please see JSONRPC2.Servers.HTTP.
If you wish to mount a JSON-RPC 2.0 handler in an existing Plug-based web application (such as Phoenix), you can do so by putting this in your router:
forward "/jsonrpc", JSONRPC2.Servers.HTTP.Plug, YourJSONRPC2HandlerModuleThe above code will mount the handler YourJSONRPC2HandlerModule at the path
"/jsonrpc".
The Plug.Parsers module for JSON is automatically included in the pipeline,
and will use the same serializer as is defined in the :serializer key of the
:jsonrpc2 application. You can override the default options (which are used
in this example) like so:
forward "/jsonrpc", JSONRPC2.Servers.HTTP.Plug, [
handler: YourJSONRPC2HandlerModule,
plug_parsers_opts: [
parsers: [:json],
pass: ["*/*"],
json_decoder: Application.get_env(:jsonrpc2, :serializer)
]
] Link to this section Summary
Link to this section Functions
Callback implementation for Plug.call/2.
Callback implementation for Plug.init/1.