Git Product home page Git Product logo

faraday_middleware-reddit's Introduction

FaradayMiddleware::Reddit

A collection of Faraday middleware for use with the Reddit API.

This project is the backbone for reddit-base. If you're building a client from scratch or just want to get up and running quickly you might want to check it out instead.

Installation

Add this line to your application's Gemfile:

gem 'faraday_middleware-reddit'

And then execute:

$ bundle

Or install it yourself as:

$ gem install faraday_middleware-reddit

Requirements

faraday and faraday_middleware are currently gemspec dependencies.

Like faraday_middleware, faraday_middleware-reddit requires a json library. Ruby versions prior to 1.9 will need to have one installed.

Usage

faraday_middleware-reddit currently provides the following middleware:

Middleware Type Description
:reddit_authentication request Authentication based on a username, password or pre-generated cookie.
:reddit_force_json use Coerces reddit into returnign JSON for GET and POST requests.
:reddit_modhash use Automatic modhash handling.
:reddit_raise_error response Raises errors for common reddit error cases.
:reddit_rate_limit use Rate limiting based on reddit's x-ratelimit headers. Accepts a strategy proc to override default linear strategy.

Examples

An example Farday client might look like:

require 'faraday_middleware/reddit'

conn = Faraday.new(url: 'http://www.reddit.com', headers: {'User-Agent' => 'faraday_middleware-reddit example (v 0.0.1)'}) do |faraday|
  faraday.request  :url_encoded
  faraday.request  :reddit_authentication, user: 'yourusername', password: 'yourpassword'
  faraday.request  :retry, max: 2, interval: 2, exceptions: FaradayMiddleware::Reddit::RETRIABLE_ERRORS

  faraday.response :logger
  faraday.response :follow_redirects
  faraday.response :reddit_raise_error

  faraday.use  :reddit_force_json
  faraday.use  :reddit_rate_limit
  faraday.use  :reddit_modhash

  faraday.adapter  Faraday.default_adapter
end

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Contributors

This project is copyright 2014 by its contributors, licensed under Apache License 2.0.

faraday_middleware-reddit's People

Contributors

dobs avatar ibazylchuk avatar

Watchers

 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.