Skip to content

Commit

Permalink
Minor README improvements.
Browse files Browse the repository at this point in the history
  • Loading branch information
rkh committed Oct 12, 2010
1 parent 6306a9f commit b73158a
Showing 1 changed file with 15 additions and 16 deletions.
31 changes: 15 additions & 16 deletions README.rdoc
Expand Up @@ -126,8 +126,8 @@ on to the HTTP client, or at least the next middleware in the Rack stack.
Most commonly this is a string, as in the above examples. But other values are
also accepted.

You can return any object that would either be a valid Rack response, Rack body object
or HTTP status code:
You can return any object that would either be a valid Rack response, Rack
body object or HTTP status code:

* An Array with three elements: <tt>[status (Fixnum), headers (Hash), response body (responds to #each)]</tt>
* An Array with two elements: <tt>[status (Fixnum), response body (responds to #each)]</tt>
Expand Down Expand Up @@ -302,7 +302,6 @@ other templates.

Templates may be defined at the end of the source file:

require 'rubygems'
require 'sinatra'

get '/' do
Expand Down Expand Up @@ -362,9 +361,9 @@ route handlers and templates:

== Filters

Before filters are evaluated before each request within the context of the
request and can modify the request and response. Instance variables set in
filters are accessible by routes and templates:
Before filters are evaluated before each request within the same context as
the routes will be and can modify the request and response. Instance variables
set in filters are accessible by routes and templates:

before do
@note = 'Hi!'
Expand All @@ -376,9 +375,9 @@ filters are accessible by routes and templates:
params[:splat] #=> 'bar/baz'
end

After filter are evaluated after each request within the context of the
request and can also modify the request and response. Instance variables
set in before filters and routes are accessible by after filters:
After filter are evaluated after each request within the same context and can
also modify the request and response. Instance variables set in before filters
and routes are accessible by after filters:

after do
puts response.status
Expand All @@ -390,19 +389,19 @@ To immediately stop a request within a filter or route use:

halt

You can also specify the status when halting ...
You can also specify the status when halting:

halt 410

Or the body ...
Or the body:

halt 'this will be the body'

Or both ...
Or both:

halt 401, 'go away!'

With headers ...
With headers:

halt 402, {'Content-Type' => 'text/plain'}, 'revenge'

Expand Down Expand Up @@ -447,16 +446,16 @@ Run when the environment is set to either <tt>:production</tt> or
== Error handling

Error handlers run within the same context as routes and before filters, which
means you get all the goodies it has to offer, like <tt>haml</tt>, <tt>erb</tt>,
<tt>halt</tt>, etc.
means you get all the goodies it has to offer, like <tt>haml</tt>,
<tt>erb</tt>, <tt>halt</tt>, etc.

=== Not Found

When a <tt>Sinatra::NotFound</tt> exception is raised, or the response's status
code is 404, the <tt>not_found</tt> handler is invoked:

not_found do
'This is nowhere to be found'
'This is nowhere to be found.'
end

=== Error
Expand Down

0 comments on commit b73158a

Please sign in to comment.