-
-
Save shinzui/87149 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'sinatra' | |
module Sinatra::Metal | |
module ClassMethods | |
def metal(base = nil) | |
base = '' unless base || @metal | |
@metal = /^#{Regexp.escape base}/ if base | |
@metal | |
end | |
end | |
def self.included(base) | |
base.extend ClassMethods | |
base.disable :raise_errors | |
base.app_file caller.first.split(':').first | |
base.before { not_found unless request.path_info =~ self.class.metal } | |
base.metal | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'sinatra/metal' | |
class SinatraMetal < Sinatra::Base | |
include Sinatra::Metal | |
get '/sinatra' do | |
'hello sinatra!' | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment