Using Rack Middleware
You can read through the RubyLearning FAQ .
Here are some of the fun apps created by the previous batch participants and deployed to:
A app to access via GeoCoder
Using Sinatra to access the . … API
Optional:Middleware with Saral
Exercise 8 -modified
Exercise 9 - Saral Web Service: Sorter
How to upload yourto
How to upload your app to
Exercise 10 - Handling Exceptions
Exercise 11 -Gem and
The course contents are subject to change.
Satish Talim and Victor Goff III from the team.
Middleware to re-route requests based on their port number: class PortMap def initialize(default_app, mappings) @default_app = default_app @ mappings = mappings end
def call(env) request = Rack::Request.new(env) port = request.port app = @ mappings[port] || @default_app app.call(env) end end
We can now use this in a Capybara + Rack::Test suite: original_app = Capybara.app
Capybara.app = PortMap.new( original_app, 1234 => MyFakeCreditCardGateway, …
Middleware to the Rescue
Fortunately, it's easy to write custom middleware that rescue s the errors thrown when JSON can't be parsed. To wit, the version for rails 3.2: # in app/middleware/catch_json_parse_errors.rb class CatchJsonParseErrors def initialize(app) @app = app end
def call(env) begin @app.call(env) rescue MultiJson::LoadError => error if env['HTTP_ACCEPT'] =~ /application\/json/ error_output = "There was a problem …
If you subclass from:: :: Middleware you'll get the first for free. contexts is an array of search context objects, which provide access to each search object along with the raw search results and other pieces of information to note between middleware objects. Middleware are written to handle multiple search requests, hence why contexts is an array.
If you're looking for inspiration on how to write your own middleware, have a look through the source …
Open Source - - Figure out which are your hot keys. Top
Instant - A full book on using Firebug effectively. Starter
Future of Firebug Lite - The project is looking for folks to work on it.
Brainrubyck - A interpreter written in Ruby.
Turkee - Mechanical Turk integration for projects.
Rack::Attack - Middleware for throttling requests from abusive clients.
Just by building your application with Ruby on Rails 3.1+, there are a number of performance features that you get just by following the Rails conventions. These are features that make your application faster to your users, and faster applications have been shown to have happier users.
And you get them all for Free!
ETags for All Content
Today: Girl Scouts. Tomorrow: 12-mile hike. Somewhere in there: code.
Zapier - for various online services with a drag-and-drop trigger/action builder.
Cachex : tag based fragment caching on steroids - Another cache invalidation strategy for apps with nested partials.
rack-attack - Middleware to handle whitelisting, blacklisting, and throttling.
Git Landscaping - How to clean up old remote feature branches.
Rack-Policy: Middleware for Complying With the ePrivacy Directive
If you're not based in the EU, you can ignore this idiotic piece of legislation but otherwise Rack-Policy helps your Ruby webapps comply with getting implied consent before any cookies can be stored on your visitors' machines.
Image Sorcery: A Ruby ImageMagick 'That 't Suck'
Image Sorcery leverages all three of ImageMagick's command line tools, …
Rack middleware for defining a single hostname as the canonical host for your app. Requests for other hostnames will get redirected to the canonical host.
Aspector: ( AOP) for Ruby
A phonetic algorithm matches two different words with similar pronunciation to the same code, which allows phonetic …