Coder Social home page Coder Social logo

ur's Introduction

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:

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:

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

Ur is licensed under the terms of the GNU Lesser General Public License version 3.

ur's People

Contributors

notethan avatar dependabot-preview[bot] avatar

Watchers

 avatar James Cloos avatar

ur's Issues

Dependabot couldn't fetch the branch/reference for jsi.git

Your dependency file specified a branch or reference for jsi.git, but Dependabot couldn't find it at the project's source. Has it been removed?

For Ruby dependencies, this can be caused by a branch specified in your Gemfile being deleted at the source, or having been rebased, so the commit reference in your Gemfile.lock is no longer included in the branch. In that case, it can be fixed by running bundler update jsi.git locally.

View the update logs.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.