View Source PhxJsonRpc.Router (Phoenix JSON RPC v0.1.0)

The entrypoint for defining rpc routes.

example

Example

defmodule MyRpcRouter do
  use PhxJsonRpc.Router,
    schema: "[PATH_TO_OPENRPC_SCHEMA]",
    version: "2.0"

  rpc("greet", HelloController, :hello)
end

Link to this section Summary

Functions

Generates rpc route match based on the open-rpc schema parameters.

Link to this section Functions

Link to this macro

rpc(method, controller, action, schema_ref \\ nil)

View Source (macro)

Generates rpc route match based on the open-rpc schema parameters.

arguments

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.

examples

Examples

rpc("hello", HelloController, :hello)
rpc("pet_create", PetController, :create, "#/components/schemas/NewPet")