Sha256: 4c3b8d8a480f8fb967e57db1c21f78065bc6262da7f475a3a0ff1fc8bb725780

Contents?: true

Size: 1.57 KB

Versions: 3

Compression:

Stored size: 1.57 KB

Contents

# Ur áš’

Ur: Unified Request/Response Representation in Ruby

## Properties

An ur primarily consists of a request, a response, and additional metadata.

The request consists of the request method, uri, headers, and body.

The response consists of the response status, headers, and body.

The metadata consist of the time the request began, the duration of the request, or tag strings. This is optional.

Other attributes may be present, and are ignored by this library.

## Usage with middleware

Rack middleware:

```ruby
class MyRackMiddleware
  def initialize(app)
    @app = app
  end

  def call(env)
    # do things before the request

    ur = Ur.from_rack_request(env)

    # set additional properties of the ur, for example:
    ur.logger_tags(my_logger)

    rack_response = ur.with_rack_response(@app, env) do
      # do things after the response
    end
    rack_response
  end
end
```

Faraday middleware:

```ruby
class MyFaradayMiddleware < ::Faraday::Middleware
  def call(request_env)
    # do things before the request

    ur = Ur.from_faraday_request(request_env)

    # set additional properties of the ur, for example:
    ur.logger_tags(my_logger)

    ur.faraday_on_complete(@app, request_env) do |response_env|
      # do things after the response
    end
  end
end
```

## License

[<img align="right" src="https://github.com/notEthan/ur/raw/master/resources/icons/LGPL-3.0.png">](https://www.gnu.org/licenses/lgpl-3.0.html)

Ur is Open Source Software licensed under the terms of the [GNU Lesser General Public License version 3](https://www.gnu.org/licenses/lgpl-3.0.html).

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ur-0.2.1 README.md
ur-0.2.0 README.md
ur-0.1.1 README.md