Skip to content
Browse files

Options can be passed to Sinatra interface now

  • Loading branch information...
1 parent b6310d2 commit 62077f201408caf7c99667f65237109cf3518979 DanielVartanov committed Jul 17, 2010
Showing with 7 additions and 3 deletions.
  1. +7 −3 lib/usher/interface/sinatra.rb
View
10 lib/usher/interface/sinatra.rb
@@ -1,8 +1,10 @@
class Usher
module Interface
class Sinatra
+ cattr_reader :router_options
- def initialize
+ def initialize(router_options)
+ @@router_options = router_options
::Sinatra.send(:include, Extension)
end
@@ -80,12 +82,14 @@ def route(verb, path, options={}, &block)
end
def router
- @router ||= Usher.new(:request_methods => [:request_method, :host, :port, :scheme],
+ usher_options = { :request_methods => [:request_method, :host, :port, :scheme],
:ignore_trailing_delimiters => true,
:generator => Usher::Util::Generators::URL.new,
:delimiters => ['/', '.', '-'],
:valid_regex => '[0-9A-Za-z\$_\+!\*\',]+',
- :detailed_failure => true)
+ :detailed_failure => true }.merge(self.router_options)
+
+ @router ||= Usher.new(usher_options)
block_given? ? yield(@router) : @router
end

2 comments on commit 62077f2

@joshbuddy

Take a look at the sinatra interface on http_router too. I think, probably a better thing than this.

@DanielVartanov
Owner

Yes, it makes sense since I don't need special chars as path delimiters anymore. As far as I tested, escaped parentheses '(' and ')' are recognized properly by http_router

Please sign in to comment.
Something went wrong with that request. Please try again.