View Source PhxJsonRpc.Router (Phoenix JSON RPC v0.7.0)
The entrypoint for defining rpc routes.
Config
otp_app- name of the OTP application.schema- specifies path to your json-schema file.version- jsonrpc version.max_batch_size- maximum number of requests per batch.
Example
defmodule MyRpcRouter do
use PhxJsonRpc.Router,
otp_app: :rpc_router,
schema: "[PATH_TO_OPENRPC_SCHEMA]",
version: "2.0",
max_batch_size: 20
rpc("greet", HelloController, :hello)
endOTP customization (optional)
You can override pipeline for handling requests, by adding extra-params in config file.
All the options should implement specific behaviour.
If option is not present in the config, it will be setted to the package defaults.
parser- should implementPhxJsonRpc.Router.Parservalidator- should implementPhxJsonRpc.Router.Validatordispatcher- should implementPhxJsonRpc.Router.Dispatcher
Example
config :rpc_router, MyRpcRouter,
parser: MyRpc.Parser,
validator: MyRpc.Validator,
dispatcher: MyRpc.Dispatcher
Summary
Functions
Keeps user-defined middleware.
Generates rpc route match based on the open-rpc schema parameters.
Functions
Keeps user-defined middleware.
Arguments
middleware_group- enumeration of the list of middleware modules.
Examples
middleware(MyMiddlewareOne, MyMiddlewareTwo)
Generates rpc route match based on the open-rpc schema parameters.
Arguments
method- the name of the calling method.controller- resolving module, often a controller.action- resolving function in controller.schema_ref- reference inside json schema, used for request params validation (optional).
Examples
rpc("hello", HelloController, :hello)
rpc("pet_create", PetController, :create, "#/components/schemas/NewPet")