From e601730a0cbc70323c52b104395bec55d326cd58 Mon Sep 17 00:00:00 2001 From: Juan Wajnerman Date: Wed, 30 Jul 2014 19:27:25 -0300 Subject: [PATCH] Frank::Handler instance is not a global variable anymore --- src/frank.cr | 4 +--- src/frank/dsl.cr | 2 +- src/frank/handler.cr | 2 ++ 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/frank.cr b/src/frank.cr index bf17a27..48941f8 100644 --- a/src/frank.cr +++ b/src/frank.cr @@ -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 diff --git a/src/frank/dsl.cr b/src/frank/dsl.cr index c10da40..3995cde 100644 --- a/src/frank/dsl.cr +++ b/src/frank/dsl.cr @@ -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 diff --git a/src/frank/handler.cr b/src/frank/handler.cr index 0d16563..9eea1b1 100644 --- a/src/frank/handler.cr +++ b/src/frank/handler.cr @@ -1,6 +1,8 @@ require "net/http" class Frank::Handler < HTTP::Handler + INSTANCE = new + def initialize @routes = [] of Route end