Permalink
Browse files

More granular requires.

This removes the giant list of requires in lib/goliath.rb in favor of letting
each component require the pieces it needs. It also provides new files with
autoloads for the modules inside Goliath, eg, Goliath::Rack. Importantly,
this makes it possible to require 'goliath/api' seperately from
'goliath/application', meaning you can load Runner & API to bootstrap the
server without the magic in Application.
  • Loading branch information...
1 parent a4cfd99 commit ea792ff58bca49f622cb68fe81b07e32cd4af553 Dean Strelau committed Jun 22, 2011
View
@@ -1,49 +1,2 @@
-require 'eventmachine'
-require 'http/parser'
-require 'async_rack'
-require 'stringio'
-
-require 'goliath/version'
-require 'goliath/goliath'
-require 'goliath/runner'
-require 'goliath/server'
-require 'goliath/constants'
-require 'goliath/connection'
-require 'goliath/request'
-require 'goliath/response'
-require 'goliath/headers'
-require 'goliath/http_status_codes'
-require 'goliath/validation/error'
-require 'goliath/validation/standard_http_errors'
-
-require 'goliath/rack/validator'
-require 'goliath/rack/async_middleware'
-require 'goliath/rack/async_aroundware'
-require 'goliath/synchrony/response_receiver'
-
-require 'goliath/rack/builder'
-require 'goliath/rack/default_response_format'
-require 'goliath/rack/heartbeat'
-require 'goliath/rack/params'
-require 'goliath/rack/render'
-require 'goliath/rack/default_mime_type'
-require 'goliath/rack/tracer'
-
-require 'goliath/rack/formatters/json'
-require 'goliath/rack/formatters/html'
-require 'goliath/rack/formatters/xml'
-require 'goliath/rack/formatters/yaml'
-require 'goliath/rack/formatters/plist'
-require 'goliath/rack/jsonp'
-
-require 'goliath/rack/validation/request_method'
-require 'goliath/rack/validation/required_param'
-require 'goliath/rack/validation/required_value'
-require 'goliath/rack/validation/numeric_range'
-require 'goliath/rack/validation/default_params'
-require 'goliath/rack/validation/boolean_value'
-
require 'goliath/api'
-
require 'goliath/application'
-
View
@@ -1,7 +1,9 @@
+require 'http_router'
+require 'goliath/goliath'
require 'goliath/response'
require 'goliath/request'
-require 'goliath/rack/validator'
-require 'goliath/validation/error'
+require 'goliath/rack'
+require 'goliath/validation'
module Goliath
# All Goliath APIs subclass Goliath::API. All subclasses _must_ override the
@@ -1,3 +1,7 @@
+require 'goliath/goliath'
+require 'goliath/runner'
+require 'goliath/rack'
+
module Goliath
# The main execution class for Goliath. This will execute in the at_exit
# handler to run the server.
@@ -1,5 +1,7 @@
require 'http/parser'
require 'goliath/env'
+require 'goliath/constants'
+require 'goliath/request'
module Goliath
# The Goliath::Connection class handles sending and receiving data
View
@@ -1,6 +1,8 @@
require 'eventmachine'
require 'http/parser'
require 'async_rack'
+require 'goliath/constants'
+require 'goliath/version'
# The Goliath Framework
module Goliath
View
@@ -0,0 +1,18 @@
+module Goliath
+ module Rack
+ autoload :AsyncAroundware, 'goliath/rack/async_aroundware'
+ autoload :AsyncMiddleware, 'goliath/rack/async_middleware'
+ autoload :Builder, 'goliath/rack/builder'
+ autoload :DefaultMimeType, 'goliath/rack/default_mime_type'
+ autoload :DefaultResponseFormat, 'goliath/rack/default_response_format'
+ autoload :Formatters, 'goliath/rack/formatters'
+ autoload :Heartbeat, 'goliath/rack/heartbeat'
+ autoload :JSONP, 'goliath/rack/jsonp'
+ autoload :Params, 'goliath/rack/params'
+ autoload :Render, 'goliath/rack/render'
+ autoload :Templates, 'goliath/rack/templates'
+ autoload :Tracer, 'goliath/rack/tracer'
+ autoload :Validator, 'goliath/rack/validator'
+ autoload :Validation, 'goliath/rack/validation'
+ end
+end
@@ -0,0 +1,11 @@
+module Goliath
+ module Rack
+ module Formatters
+ autoload :HTML, 'goliath/rack/formatters/html'
+ autoload :JSON, 'goliath/rack/formatters/json'
+ autoload :Plist, 'goliath/rack/formatters/plist'
+ autoload :XML, 'goliath/rack/formatters/xml'
+ autoload :YAML, 'goliath/rack/formatters/yaml'
+ end
+ end
+end
@@ -0,0 +1,12 @@
+module Goliath
+ module Rack
+ module Validation
+ autoload :BooleanValue, 'goliath/rack/validation/boolean_value'
+ autoload :DefaultParams, 'goliath/rack/validation/default_params'
+ autoload :NumericRange, 'goliath/rack/validation/numeric_range'
+ autoload :RequestMethod, 'goliath/rack/validation/request_method'
+ autoload :RequiredParam, 'goliath/rack/validation/required_param'
+ autoload :RequiredValue, 'goliath/rack/validation/required_value'
+ end
+ end
+end
View
@@ -1,5 +1,7 @@
require 'eventmachine'
require 'goliath/constants'
+require 'goliath/response'
+require 'goliath/validation'
require 'async_rack'
require 'stringio'
@@ -0,0 +1,2 @@
+require 'goliath/validation/error'
+require 'goliath/validation/standard_http_errors'

0 comments on commit ea792ff

Please sign in to comment.