Custom Plugins

By now, you know that most of the features from this library are added as plugins.

Plugins are nothing but a pattern following a known convention. In order for you to write a plugin, you need to create a module and register it (we suggest you to put it under “lib/httpx/plugins” in your project):

# lib/httpx/plugins/custom.rb
module HTTPX::Plugins
  module Custom
  ...
  end
  register :custom, Custom
end

Once you have it, when loaded, your plugin will:

  • load dependencies
  • decorate certain internal resources
  • configure

All of these steps are optional.

You’re kindly invited to look at the implementations of the plugins to understand how this is done.

Next: Adapters