Module: JSONRPC::MapperExtension Private

Defined in:
lib/jsonrpc/railtie/mapper_extension.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Extension module for ActionDispatch::Routing::Mapper

Instance Method Summary collapse

Instance Method Details

#jsonrpc(path = '/') ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Define JSON-RPC routes with a DSL

Examples:

Define JSON-RPC routes

jsonrpc '/api/v1' do
  # Handle batch requests
  batch to: 'batch#handle'

  method 'user.create', to: 'users#create'
  method 'user.get', to: 'users#show'

  namespace 'posts' do
    method 'create', to: 'posts#create'
    method 'list', to: 'posts#index'
  end
end

Parameters:

  • path (String) (defaults to: '/')

    the path to handle JSON-RPC requests on



29
30
31
32
# File 'lib/jsonrpc/railtie/mapper_extension.rb', line 29

def jsonrpc(path = '/', &)
  dsl = JSONRPC::RoutesDsl.new(self, path)
  dsl.instance_eval(&)
end