Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Commit

Permalink
add content for RackMiddleware
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Schneider <chris@christopher-schneider.com>
  • Loading branch information
taylorrf authored and cschneid committed Dec 28, 2008
1 parent 94751c0 commit afb57f8
Show file tree
Hide file tree
Showing 22 changed files with 25 additions and 3 deletions.
Empty file modified .gitignore 100644 → 100755
Empty file.
Empty file modified CONTRIBUTING 100644 → 100755
Empty file.
Empty file modified TODO 100644 → 100755
Empty file.
Empty file modified assets/book.css 100644 → 100755
Empty file.
Empty file modified book-order.txt 100644 → 100755
Empty file.
Empty file modified book/.gitignore 100644 → 100755
Empty file.
Empty file modified book/Configuration.markdown 100644 → 100755
Empty file.
Empty file modified book/Contributing.markdown 100644 → 100755
Empty file.
Empty file modified book/Deployment.markdown 100644 → 100755
Empty file.
Empty file modified book/ErrorHandling.markdown 100644 → 100755
Empty file.
Empty file modified book/Filters.markdown 100644 → 100755
Empty file.
Empty file modified book/Handlers.markdown 100644 → 100755
Empty file.
Empty file modified book/Helpers.markdown 100644 → 100755
Empty file.
Empty file modified book/Introduction.markdown 100644 → 100755
Empty file.
Empty file modified book/Models.markdown 100644 → 100755
Empty file.
28 changes: 25 additions & 3 deletions book/RackMiddleware.markdown 100644 → 100755
@@ -1,8 +1,30 @@
Rack Middleware Rack Middleware
=============== ===============


"use" Sinatra rides on [Rack][rack], a minimal standard interface for Ruby web frameworks. One of Rack’s most interesting capabilities for application developers is support for “middleware” — components that sit between the server and your application monitoring and/or manipulating the HTTP request/response to provide various types of common functionality.
-----


// TODO: What useful rack middleware is out there? Is there any 3rd party stuff available outside of the builtin ones? Sinatra makes building Rack middleware pipelines a cinch via a top-level "use" method:

require 'sinatra'
require 'my_custom_middleware'

use Rack::Lint
use MyCustomMiddleware

get '/hello' do
'Hello World'
end


The semantics of "use" are identical to those defined for the [Rack::Builder][rack_builder] DSL (most frequently used from rackup files). For example, the use method accepts multiple/variable args as well as blocks:

use Rack::Auth::Basic do |username, password|
username == 'admin' && password == 'secret'
end


Rack is distributed with a variety of standard middleware for logging, debugging, URL routing, authentication, and session handling. Sinatra uses many of of these components automatically based on configuration so you typically don’t have to use them explicitly.

[rack]: http://rack.rubyforge.org/
[rack_builder]: http://rack.rubyforge.org/doc/classes/Rack/Builder.html


Empty file modified book/Routes.markdown 100644 → 100755
Empty file.
Empty file modified book/TOC.markdown 100644 → 100755
Empty file.
Empty file modified book/Views.markdown 100644 → 100755
Empty file.
Empty file modified images/.gitignore 100644 → 100755
Empty file.
Empty file modified sinatra-book.thor 100644 → 100755
Empty file.
Empty file modified source/.gitignore 100644 → 100755
Empty file.

0 comments on commit afb57f8

Please sign in to comment.