Frank::Handler instance is not a global variable anymore

This commit is contained in:
Juan Wajnerman 2014-07-30 19:27:25 -03:00
parent 69ed2d4612
commit e601730a0c
3 changed files with 4 additions and 4 deletions

View File

@ -1,8 +1,6 @@
require "option_parser"
require "./frank/*"
$frank_handler = Frank::Handler.new
at_exit do
OptionParser.parse! do |opts|
opts.on("-p ", "--port ", "port") do |opt_port|
@ -14,7 +12,7 @@ at_exit do
handlers = [] of HTTP::Handler
handlers << HTTP::LogHandler.new
handlers << HTTP::StaticFileHandler.new("./public")
handlers << $frank_handler
handlers << Frank::Handler::INSTANCE
server = HTTP::Server.new(config.port, handlers)
server.ssl = config.ssl

View File

@ -1,3 +1,3 @@
def get(path, &block : Frank::Request -> String)
$frank_handler.add_route(path, block)
Frank::Handler::INSTANCE.add_route(path, block)
end

View File

@ -1,6 +1,8 @@
require "net/http"
class Frank::Handler < HTTP::Handler
INSTANCE = new
def initialize
@routes = [] of Route
end