{"id":28744762,"url":"https://github.com/wilsonsilva/jsonrpc-middleware","last_synced_at":"2026-03-14T16:40:26.707Z","repository":{"id":299062888,"uuid":"988645759","full_name":"wilsonsilva/jsonrpc-middleware","owner":"wilsonsilva","description":"Ruby implementation of the JSON-RPC 2.0 protocol for Rack-based applications.","archived":false,"fork":false,"pushed_at":"2025-09-17T05:37:42.000Z","size":255,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-07T21:55:38.570Z","etag":null,"topics":["json-rpc","json-rpc2","jsonrpc","jsonrpc2","middleware","rack","rails","ruby","ruby-gem","ruby-on-rails"],"latest_commit_sha":null,"homepage":"https://jsonrpc-middleware.com","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wilsonsilva.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-05-22T21:28:59.000Z","updated_at":"2025-09-17T05:37:45.000Z","dependencies_parsed_at":null,"dependency_job_id":"bdb80f60-4e63-40cc-9ba2-e1b55351c83c","html_url":"https://github.com/wilsonsilva/jsonrpc-middleware","commit_stats":null,"previous_names":["wilsonsilva/jsonrpc-middleware"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/wilsonsilva/jsonrpc-middleware","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wilsonsilva%2Fjsonrpc-middleware","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wilsonsilva%2Fjsonrpc-middleware/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wilsonsilva%2Fjsonrpc-middleware/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wilsonsilva%2Fjsonrpc-middleware/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wilsonsilva","download_url":"https://codeload.github.com/wilsonsilva/jsonrpc-middleware/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wilsonsilva%2Fjsonrpc-middleware/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":283910127,"owners_count":26915128,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-11-11T02:00:06.610Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["json-rpc","json-rpc2","jsonrpc","jsonrpc2","middleware","rack","rails","ruby","ruby-gem","ruby-on-rails"],"created_at":"2025-06-16T12:05:29.101Z","updated_at":"2025-11-11T18:38:57.115Z","avatar_url":"https://github.com/wilsonsilva.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://jsonrpc-middleware.com\" target=\"_blank\"\u003e\n    \u003cpicture\u003e\n      \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"./.github/images/logo-dark.svg\"\u003e\n      \u003csource media=\"(prefers-color-scheme: light)\" srcset=\"./.github/images/logo-light.svg\"\u003e\n      \u003cimg alt=\"JSON-RPC Middleware Logo\" src=\"./.github/images/logo-light.svg\" width=\"600\" height=\"120\" style=\"max-width: 100%;\"\u003e\n    \u003c/picture\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n\u003cdiv align=\"center\"\u003e\n\n[![Gem Version](https://badge.fury.io/rb/jsonrpc-middleware.svg)](https://badge.fury.io/rb/jsonrpc-middleware)\n![Build](https://github.com/wilsonsilva/jsonrpc-middleware/actions/workflows/main.yml/badge.svg)\n[![Maintainability](https://qlty.sh/badges/a275de81-94e3-45af-9469-523aa5345871/maintainability.svg)](https://qlty.sh/gh/wilsonsilva/projects/jsonrpc-middleware)\n[![Code Coverage](https://qlty.sh/badges/a275de81-94e3-45af-9469-523aa5345871/test_coverage.svg)](https://qlty.sh/gh/wilsonsilva/projects/jsonrpc-middleware)\n\n\u003c/div\u003e\n\nA Rack middleware implementing the JSON-RPC 2.0 protocol that integrates easily with all Rack-based applications (Rails, Sinatra, Hanami, etc).\n\n## Table of contents\n\n- [Key features](#-key-features)\n- [Installation](#-installation)\n- [Quickstart](#-quickstart)\n- [Examples](#-examples)\n- [Documentation](#-documentation)\n- [Development](#-development)\n  * [Type checking](#-type-checking)\n- [Contributing](#-contributing)\n- [License](#-license)\n- [Code of Conduct](#-code-of-conduct)\n\n## 🔑 Key features\n\n- **Spec-compliant**: Fully implements the [JSON-RPC 2.0 specification](https://www.jsonrpc.org/specification)\n- **Rack middleware integration**: Seamlessly integrates with Rack applications (Rails, Sinatra, Hanami, etc)\n- **Support for all request types**: Handles single requests, notifications, and batch requests\n- **Rails routing DSL**: Elegant routing DSL for Rails applications with support for namespaces and batch handling\n- **Error handling**: Comprehensive error handling with standard JSON-RPC error responses\n- **Request validation**: Define request parameter specifications and validations\n- **Helpers**: Convenient helper methods to simplify request and response processing\n- **Optimized JSON handling**: Uses MultiJSON to automatically select the fastest available JSON library\n\n## 🏗️ Architecture\n\nThe gem integrates seamlessly into your Rack-based application:\n\n```mermaid\nblock-beta\n  columns 4\n\n  App[\"Your app\"]:4\n  Rails:1 Sinatra:1 RackApp[\"Other Rack-compatible framework\"]:2\n  Middleware[\"JSON-RPC Middleware\"]:4\n  Rack[\"Rack\"]:4\n  HTTP[\"HTTP\"]:4\n\n  classDef middlewareStyle fill:#ff6b6b,stroke:#d63031,stroke-width:2px,color:#fff\n  class Middleware middlewareStyle\n```\n\n## 📦 Installation\n\nInstall the gem and add to the application's Gemfile by executing:\n\n    $ bundle add jsonrpc-middleware\n\nIf bundler is not being used to manage dependencies, install the gem by executing:\n\n    $ gem install jsonrpc-middleware\n\n## ⚡️ Quickstart\n\nCreate a file called `config.ru` and run `bundle exec rackup`:\n\n```ruby\n# frozen_string_literal: true\n\nrequire 'bundler/inline'\n\ngemfile do\n  source 'https://rubygems.org'\n\n  gem 'jsonrpc-middleware', require: 'jsonrpc'\n  gem 'puma'\n  gem 'rack'\n  gem 'rackup'\nend\n\nJSONRPC.configure do\n  procedure(:add, allow_positional_arguments: true) do\n    params do\n      required(:addends).filled(:array)\n      required(:addends).value(:array).each(type?: Numeric)\n    end\n\n    rule(:addends) do\n      key.failure('must contain at least one addend') if value.empty?\n    end\n  end\nend\n\nclass App\n  include JSONRPC::Helpers\n\n  def call(env)\n    @env = env\n\n    if jsonrpc_request?\n      sum = add(jsonrpc_request.params)\n      jsonrpc_response(sum)\n    elsif jsonrpc_notification?\n      add(jsonrpc_notification.params)\n      jsonrpc_notification_response\n    else\n      results = add_in_batches(jsonrpc_batch)\n      jsonrpc_batch_response(results)\n    end\n  end\n\n  private\n\n  def add(params)\n    addends = params.is_a?(Array) ? params : params['addends'] # Handle positional and named arguments\n    addends.sum\n  end\n\n  def add_in_batches(batch)\n    batch.process_each { |request_or_notification| add(request_or_notification.params) }\n  end\nend\n\nuse JSONRPC::Middleware\nrun App.new\n```\n\nThis will give you a fully-featured JSON-RPC server, capable of:\n- Handling JSON-RPC requests, notifications __and batches__\n- Validating the allowed JSON-RPC methods (e.g. allow only `add`)\n- Validating the JSON-RPC method parameters (e.g. allow only non-empty arrays of numbers)\n- Accept positional and named parameters (`params: [5, 5]`, `params: { addends: [5, 5] }`)\n- Respond successfully or erroneously, according to the specification\n\nFor more advanced setups, or other frameworks such as Rails or Sinatra, check the [examples](https://github.com/wilsonsilva/jsonrpc-middleware/blob/main/examples/README.md).\n\n## 📚 Documentation\n\n- [YARD documentation](https://rubydoc.info/gems/jsonrpc-middleware)\n\n## 📜 Examples\n\nExamples for the most common Rack-based applications, including Rails and Sinatra can be found [here](https://github.com/wilsonsilva/jsonrpc-middleware/blob/main/examples/README.md)\n\n## 🔨 Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies.\n\nTo install this gem onto your local machine, run `bundle exec rake install`.\n\nYou can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`,\nwhich will create a git tag for the version, push git commits and the created tag, and push the `.gem` file\nto [rubygems.org](https://rubygems.org).\n\nThe health and maintainability of the codebase is ensured through a set of\nRake tasks to test, lint and audit the gem for security vulnerabilities and documentation:\n\n```\nrake build                    # Build jsonrpc-middleware.gem into the pkg directory\nrake build:checksum           # Generate SHA512 checksum of jsonrpc-middleware.gem into the checksums directory\nrake bundle:audit:check       # Checks the Gemfile.lock for insecure dependencies\nrake bundle:audit:update      # Updates the bundler-audit vulnerability database\nrake clean                    # Remove any temporary products\nrake clobber                  # Remove any generated files\nrake coverage                 # Run spec with coverage\nrake examples:bundle_install  # Run bundle install on all example folders (useful after updating the gem version)\nrake install                  # Build and install jsonrpc-middleware.gem into system gems\nrake install:local            # Build and install jsonrpc-middleware.gem into system gems without network access\nrake qa                       # Test, lint and perform security and documentation audits\nrake release[remote]          # Create tag v0.1.0 and build and push jsonrpc-middleware-0.1.0.gem to rubygems.org\nrake rubocop                  # Run RuboCop\nrake rubocop:autocorrect      # Autocorrect RuboCop offenses (only when it's safe)\nrake rubocop:autocorrect_all  # Autocorrect RuboCop offenses (safe and unsafe)\nrake spec                     # Run RSpec code examples\nrake verify_measurements      # Verify that yardstick coverage is at least 100%\nrake yard                     # Generate YARD Documentation\nrake yard:format              # Format YARD documentation\nrake yard:junk                # Check the junk in your YARD Documentation\nrake yardstick_measure        # Measure docs in lib/**/*.rb with yardstick\n```\n\n### 🧪 Type checking\n\nThis gem leverages [RBS](https://github.com/ruby/rbs), a language to describe the structure of Ruby programs. It is\nused to provide type checking and autocompletion in your editor. Run `bundle exec typeprof FILENAME` to generate\nan RBS definition for the given Ruby file. And validate all definitions using [Steep](https://github.com/soutaro/steep)\nwith the command `bundle exec steep check`.\n\n## 🐞 Issues \u0026 Bugs\n\nIf you find any issues or bugs, please report them [here](https://github.com/wilsonsilva/jsonrpc-middleware/issues), I will be happy\nto have a look at them and fix them as soon as possible.\n\n## 🤝 Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/wilsonsilva/jsonrpc-middleware.\nThis project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere\nto the [code of conduct](https://github.com/wilsonsilva/jsonrpc-middleware/blob/main/CODE_OF_CONDUCT.md).\n\n## 📜 License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n\n## 👔 Code of Conduct\n\nEveryone interacting in the JSONRPC::Middleware Ruby project's codebases, issue trackers, chat rooms and mailing lists is expected\nto follow the [code of conduct](https://github.com/wilsonsilva/jsonrpc-middleware/blob/main/CODE_OF_CONDUCT.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwilsonsilva%2Fjsonrpc-middleware","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwilsonsilva%2Fjsonrpc-middleware","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwilsonsilva%2Fjsonrpc-middleware/lists"}