Class: Hooksler::Application
- Inherits:
-
Object
- Object
- Hooksler::Application
- Defined in:
- lib/hooksler/application.rb
Class Method Summary collapse
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize ⇒ Application
constructor
A new instance of Application.
Constructor Details
#initialize ⇒ Application
Returns a new instance of Application.
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/hooksler/application.rb', line 7 def initialize @root = File.dirname ENV['BUNDLE_GEMFILE'] Dir.glob(File.join(@root, 'inputs/*.rb')).each do |file| require file end Dir.glob(File.join(@root, 'outputs/*.rb')).each do |file| require file end require File.join(@root, 'config', 'routing.rb') end |
Class Method Details
.run ⇒ Object
3 4 5 |
# File 'lib/hooksler/application.rb', line 3 def self.run self.new end |
Instance Method Details
#call(env) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/hooksler/application.rb', line 20 def call(env) req = Rack::Request.new(env) if req.path =~ /\/_endpoints_$/ ['200', {'Content-Type' => 'application/json'}, [MultiJson.dump(Hooksler::Router.info)]] else from_instance, routes = Hooksler::Router.resolve_path req.fullpath return ['410', {'Content-Type' => 'text/html'}, ['Gone']] unless from_instance = [*from_instance.load(req)].compact routes.each do |route| .each do || route.process() end end ['200', {'Content-Type' => 'text/plain'}, ['']] end rescue => e puts e puts e.backtrace ['503', {'Content-Type' => 'text/html'}, [e.to_s]] end |