Permalink
Browse files

add content for RackMiddleware

Signed-off-by: Chris Schneider <chris@christopher-schneider.com>
  • Loading branch information...
1 parent 94751c0 commit afb57f831877f7113acd5690a8e059c89c49df8b @taylorrf taylorrf committed with Dec 28, 2008
View
0 .gitignore 100644 → 100755
No changes.
View
0 CONTRIBUTING 100644 → 100755
No changes.
View
0 TODO 100644 → 100755
No changes.
View
0 assets/book.css 100644 → 100755
No changes.
View
0 book-order.txt 100644 → 100755
No changes.
View
0 book/.gitignore 100644 → 100755
No changes.
View
0 book/Configuration.markdown 100644 → 100755
No changes.
View
0 book/Contributing.markdown 100644 → 100755
No changes.
View
0 book/Deployment.markdown 100644 → 100755
No changes.
View
0 book/ErrorHandling.markdown 100644 → 100755
No changes.
View
0 book/Filters.markdown 100644 → 100755
No changes.
View
0 book/Handlers.markdown 100644 → 100755
No changes.
View
0 book/Helpers.markdown 100644 → 100755
No changes.
View
0 book/Introduction.markdown 100644 → 100755
No changes.
View
0 book/Models.markdown 100644 → 100755
No changes.
View
28 book/RackMiddleware.markdown 100644 → 100755
@@ -1,8 +1,30 @@
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
View
0 book/Routes.markdown 100644 → 100755
No changes.
View
0 book/TOC.markdown 100644 → 100755
No changes.
View
0 book/Views.markdown 100644 → 100755
No changes.
View
0 images/.gitignore 100644 → 100755
No changes.
View
0 sinatra-book.thor 100644 → 100755
No changes.
View
0 source/.gitignore 100644 → 100755
No changes.

0 comments on commit afb57f8

Please sign in to comment.