Coder Social home page Coder Social logo

http_monkey's Introduction

[Mini logo] Build Status

HTTP Monkey

A fluent interface to do HTTP calls, free of fat dependencies and at same time, powered by middlewares rack.

  • Light and powerful interface
  • Flexibility
  • Choose your HTTP adapter
  • Middlewares (More power to the people!)
  • Easy to contribute

Installation

Add this line to your application's Gemfile:

gem 'http_monkey'

And then execute:

$ bundle

Or install it yourself as:

$ gem install http_monkey

Usage

HTTP Monkey home.

Some code to make developers happy!

  agent = HttpMonkey.build

  # you can set headers, cookies, auth, proxy timeout, SSL ... all web stuff.
  # response = agent.at("http://someservice.com").
  #              with_header("Content-Type" => "application/json").
  #              basic_auth("user", "pass").
  #              get

  response = agent.at("http://google.com").get
  puts response.code  # response.headers and response.body

  # you can change settings on your client
  agent.configure do
    middlewares do
    # Default HTTP Headers (to all requests)
    use HttpMonkey::M::DefaultHeaders, {"Content-Type" => "application/json"}

    # Filter ALL requests (access to env and request objects)
    middlewares.use HttpMonkey::M::RequestFilter do |env, request|
      # HTTPI::Request, you can set proxy, timeouts, authentication etc.
      # req.proxy = "http://proxy.com"
    end

    # Enable automatic follow redirect
    middlewares.use HttpMonkey::M::FollowRedirect, :max_tries => 3
  end

  # or settings by request
  response = agent.at("http://google.com").get do
    net_adapter :curb # [:httpclient, :curb, :net_http, :em_http]
    behaviours do
      on([301, 302]) do |client, request, response|
        raise "Redirect Error"
      end
    end
  end

Development

Suggestions, bugs and pull requests, use GitHub Issues. See CONTRIBUTING for more details.

To see what has changed in recent versions of HTTP Monkey, see the CHANGELOG.

Core Team Members

Copyright

Copyright © 2012 HTTP Monkey. See LICENSE for details.

Project is a member of the OSS Manifesto.

http_monkey's People

Contributors

rogerleite avatar

Watchers

James Cloos avatar Kirill Petrenko avatar

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.