module

Responsible

Base module for top level macros and utilities.

Constants

HANDLERS = {} of ResponseType => Action

Class methods

on_client_error

Registers an Action to execute every on every ClientError response.

Source
on_informational

Registers an Action to execute every on every Informational response.

Source
on_redirection

Registers an Action to execute every on every Redirection response.

Source
on_server_error

Registers an Action to execute every on every ServerError response.

Source
on_success

Registers an Action to execute every on every Success response.

Source

Macros

parse_to(type, ignore_response_code = false, &block)

Wraps a expression that returns a supported response object into a Responsible::Response and attempts to parse this into the specified type.

Source
parse_to?(type, ignore_response_code = false, &block)

Wraps a expression that returns a supported response object into a Responsible::Response and parse this into the specified type, or nil if not compatible.

Source
parse_to_return_type(ignore_response_code = false, &block)

Wraps a expression that returns a supported response object into a Responsible::Response before attempting to parse this out into the return type of the surrounding method.

This may be used to provied a clean, minimal syntax when building methods that abstract over API calls.

def example_request : {response_field_a: String, response_field_b: Bool}
  Responsible.parse_to_return_type do
    HTTP::Client.get "https://www.example.com"
  end
end
Source
support(response_type, &block)

Adds Responsible support to the specified response type object.

ResponsibleInterface contains a minimal set of abstract methods that are compatible with HTTP::Client::Response` as well as many third-party libraries without modification. If you do need to specify an implimentation to map to other types, an option block may be used to specify the required implementations.

Source

Nested types