class PhantomProxy::AppRouterBase

Attributes

env[RW]

Public Class Methods

call(env) click to toggle source
# File lib/phantom_proxy/router/app_router.rb, line 46
def self.call(env)
  PhantomProxy::StatusInfo.connections+=1
  print_ram_usage("RAM USAGE Before")
  result=router.call(env)
  print_ram_usage("RAM USAGE After")
  PhantomProxy::StatusInfo.connections-=1
  result
end
call_controller(options, env) click to toggle source
# File lib/phantom_proxy/router/app_router.rb, line 59
def self.call_controller(options, env)
  options[:controller].respond_to?(options[:function]) ? options[:controller].send(options[:function], env) : PhantomProxy.const_get(options[:controller]).new(env).send(options[:function])
end
http_verbs() click to toggle source
# File lib/phantom_proxy/router/app_router.rb, line 35
def self.http_verbs
  @http_verbs||=["GET", "POST", "PUT", "DELETE", "HEAD"]
end
new(env) click to toggle source
# File lib/phantom_proxy/router/app_router.rb, line 10
def initialize(env)
  @env = env
end
options(opt) click to toggle source
# File lib/phantom_proxy/router/app_router.rb, line 30
def self.options(opt)
  opt = {:function => opt.to_sym} if opt.class != Hash
  {:controller => self.name, :function => :call}.merge(opt)
end
print_ram_usage(text) click to toggle source

Private Class Methods

router() click to toggle source
# File lib/phantom_proxy/router/app_router.rb, line 68
def self.router()
  (@@router ||= {})[self.name] ||= Journey::Router.new routes, {}
end
routes() click to toggle source
# File lib/phantom_proxy/router/app_router.rb, line 64
def self.routes()
  (@@routes ||= {})[self.name] ||= Journey::Routes.new
end

Public Instance Methods

next_api() click to toggle source
# File lib/phantom_proxy/router/app_router.rb, line 14
def next_api
  Http.NextApi
end
render(template_name, status_code=200, bind=nil) click to toggle source
# File lib/phantom_proxy/router/app_router.rb, line 22
def render(template_name, status_code=200, bind=nil)
  begin
    Http.Response(status_code, renderer.render(template_name, bind||binding), "html")
  rescue Errno::ENOENT => e
    Http.NotFound
  end
end
renderer() click to toggle source
# File lib/phantom_proxy/router/app_router.rb, line 18
def renderer
  @@renderer||=TemplateRenderer.create(binding)
end