Last active
December 11, 2015 05:49
-
-
Save asaaki/4555029 to your computer and use it in GitHub Desktop.
Simple Rack setup where you can move your middleware and map config to another file
This file contains 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
App = lambda do |env| | |
[ | |
200, | |
{ "Content-Type" => "text/plain" }, | |
[ | |
"Hello!\n", | |
"self in config.ru is: #{RACK_BUILDER.to_s}\n", | |
"@use = #{RACK_BUILDER.instance_variable_get(:@use)}\n", | |
"@map = #{RACK_BUILDER.instance_variable_get(:@map)}\n", | |
] | |
] | |
end |
This file contains 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
$LOAD_PATH.unshift('.') | |
# bind this instance to a constant | |
RACK_BUILDER = self | |
require 'app' | |
require 'routes' |
This file contains 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
RACK_BUILDER.instance_exec do | |
# use, map and run are working here | |
use Rack::Lock | |
map '/subtest' do | |
run App | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
easy :) I like
Should make it easier for development at least