1
0
Fork 0
mirror of https://github.com/sinatra/sinatra synced 2023-03-27 23:18:01 -04:00
Commit graph

19 commits

Author SHA1 Message Date
Ryan Tomayko
60d50062d7 Fix whitespace errors across all source files and tests
I can't stand this shit anymore.
2008-08-31 02:10:37 -07:00
Ryan Tomayko
da3439af02 Sinatra::Application as a sandbox for the DSL
Moves DSL methods previously defined on (main) to Sinatra::Application
and begins documenting them. This unifies a bunch of method names and
will allow individual Application instances to be used as a sandbox
for DSL execution.

The Sinatra::Application::FORWARD_METHODS array is a list of method
names that should be available at the top-level. A constant was created
so that its easy to tell what methods are available from top-level when
reading the API documentation. When one of the methods is invoked on
(main), the message is forwarded to the default application
(Sinatra::application).

This is in preparation for some configuration related changes and
multi-app support.
2008-04-27 23:54:43 -04:00
Victor Hugo Borja
9c85e99c99 Specs, documentation and fixes for splat'n routes 2008-04-27 20:30:40 -07:00
Blake Mizerany
d7032a0c91 using new RESTful testing 2008-04-15 19:42:46 -07:00
Blake Mizerany
abfa696f34 fixed broken test using static files intermittently 2008-04-15 19:42:46 -07:00
Ryan Tomayko
ce4cf34e77 entity_tag response helper / conditional GET support
ResponseHelpers#entity_tag sets the ETag response header and
(potentially) halts execution if an If-None-Match request header
is present matches the value given.

More information on HTTP's ETag header and conditional requests
available in RFC 2616:

http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.19
2008-04-13 06:12:19 -04:00
Ryan Tomayko
302a03cc37 last_modified response helper / conditional GET support
ResponseHelpers#last_modified sets the Last-Modified response header
and (potentially) halts execution if an If-Modified-Since request
header is present and matches the time given.
2008-04-13 06:12:19 -04:00
Ryan Tomayko
ccc19b0436 content_type response helper with mime type lookup and parameter support.
ResponseHelpers#content_type takes a media type and parameters and sets
the Content-Type response header accordingly.
2008-04-13 06:12:19 -04:00
Ryan Tomayko
d343d27d87 document and further spec out ResponseHelpers 2008-04-13 06:12:19 -04:00
Blake Mizerany
be5f5270ec bringing back the string.
Symbols are not garbage collected and I don't want to use the large (but cool) HashWithIndifferentAccess.  I could use OpenStruct ala camping but that seems unnecessary.

Long live the string.
2008-03-31 18:48:59 -07:00
Blake Mizerany
1f204991c3 getting mare advanced with to_result 2008-03-24 17:35:42 -07:00
Ryan Tomayko
b47ffd392a HEAD support and Static as GET/HEAD only event.
Implement HEAD by delegating to GET handlers (when no HEAD handler registered)
and removing response body. This fixes a problem where Sinatra sent a 404
response to HEAD requests due to HEAD not having any registered handlers.

While here, make Static handlers respond only to GET and HEAD requests instead
of using GET semantics for PUT/POST/DELETE. Makes it possible for Events to
register PUT/POST/DELETE handlers for static file URLs. For instance, assuming a
file exists, `public/foo.xml`, and the following event:

    put '/foo.xml' do
      File.open('public/foo.xml', 'wb') do |io|
        io.write(request.body.read)
      end
      ''
    end

    get '/foo.xml' do
      "THIS NEVER HAPPENS ... as long as /foo.xml exists on disk."
    end

The built-in Static handler hits on GET and the dynamic event hits on PUT. An
important note here is that the Static handler is now registered at the head of
the events[:get] array (see Application#load_default_events! and
Application#lookup), where it was previously a special case in the lookup
method.
2008-03-12 17:00:49 -04:00
Ryan Tomayko
b18102be44 Fix a few minor issues with, and document, the POST _method hack.
The original issue I ran into was that the code was not letting downcase method
names through on the _method param. So, if the post body had "_method=put"
instead of "_method=PUT", it would be processed as a POST. While there, I fixed
a few other cases, including the following:

  * Allow for verbs other than PUT/DELETE. OPTIONS and HEAD were added but
    additional verbs can be added on an app-by-app basis by cat'ing onto the
    POST_TUNNEL_METHODS_ALLOWED array.

  * Only look for _method param in POST body, not in query string. The code
    previously used Request#params, which includes query string and post body
    parameters.

This patch includes tests that verify each of the previously described
behaviors.
2008-03-12 16:29:21 -04:00
Blake Mizerany
0fa5de7484 making better use of Rack::Request 2008-03-04 16:45:19 -08:00
Blake Mizerany
d41cccae7b less code = great code 2008-02-20 23:46:29 -08:00
Blake Mizerany
24377ca50c FIX: Allow event to return nil without failure 2008-02-19 19:51:39 -08:00
Blake Mizerany
b72f00cc22 this should be stop and body= should go to @response 2007-11-28 21:28:59 -08:00
Blake Mizerany
de6f9818b9 Using :halt to set body 2007-11-28 13:25:14 -08:00
Blake Mizerany
d9cad760a2 throw :halt 2007-11-28 02:55:19 -08:00