rom-rb / rom-http

Abstract HTTP adapter for ROM
https://rom-rb.org
MIT License
73 stars 18 forks source link

Default handlers #40

Closed solnic closed 5 years ago

solnic commented 5 years ago

This adds default JSON request/response handlers. This should make getting started with this adapter much nicer. In addition to that, I added a way of registering your own handlers.

Here's an example:

# use built-in JSON handlers for all datasets
ROM::Configuration.new(:http, uri: "https://api.github.com", handlers: :json)

# register your own handlers
ROM::HTTP::Handlers.register(:my_handlers, request: MyRequestHandler, response: MyResponseHandler)

# voilà
ROM::Configuration.new(:http, uri: "https://api.github.com", handlers: :my_handlers)

Closes #17