lib/rack/api/runner.rb in rack-api-1.0.2 vs lib/rack/api/runner.rb in rack-api-1.1.0

- old
+ new

@@ -1,14 +1,14 @@ module Rack class API class Runner - HTTP_METHODS = %w[get post put delete head] + HTTP_METHODS = %w[get post put delete head patch options] DELEGATE_METHODS = %w[ version use prefix basic_auth rescue_from helper respond_to default_url_options - get post put delete head + get post put delete head patch options ] attr_accessor :settings def initialize @@ -212,11 +212,11 @@ # Define a new routing that will be triggered when both request method and # path are recognized. # # You're better off using all verb shortcut methods. Implemented verbs are - # +get+, +post+, +put+, +delete+ and +head+. + # +get+, +post+, +put+, +delete+, +head+ and +patch+. # # class MyAPI < Rack::API # version "v1" do # get "users(.:format)" do # # do something @@ -248,11 +248,13 @@ # # Note that your controller <b>must</b> inherit from Rack::API::Controller. Otherwise, # your world will explode. # def route(method, path, requirements = {}, &block) - path = Rack::Mount::Strexp.compile mount_path(path), requirements, %w[ / . ? ] + separator = requirements.delete(:separator) { %w[ / . ? ] } + + path = Rack::Mount::Strexp.compile mount_path(path), requirements, separator controller_class = Controller if requirements[:to] controller_name, action_name = requirements.delete(:to).split("#") controller_class = controller_name.camelize.constantize @@ -272,10 +274,10 @@ # Rescue from the specified exception. # # rescue_from ActiveRecord::RecordNotFound, :status => 404 # rescue_from Exception, :status => 500 - # rescue_from Exception do + # rescue_from Exception do |error| # $logger.error error.inspect # [500, {"Content-Type" => "text/plain"}, []] # end # def rescue_from(exception, options = {}, &block)