Class: PhantomProxy::AppRouterBase
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Jsonizer
json_var, json_vars
Methods included from Logable
#logger, #logger=, next_id
#render_json, #render_xml, #to_json, #to_xml
Constructor Details
Returns a new instance of AppRouterBase.
10
11
12
|
# File 'lib/phantom_proxy/router/app_router.rb', line 10
def initialize(env)
@env = env
end
|
Instance Attribute Details
#env ⇒ Object
Returns the value of attribute env.
8
9
10
|
# File 'lib/phantom_proxy/router/app_router.rb', line 8
def env
@env
end
|
Class Method Details
.call(env) ⇒ Object
46
47
48
49
50
51
52
53
|
# 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) ⇒ Object
59
60
61
|
# 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 ⇒ Object
35
36
37
|
# File 'lib/phantom_proxy/router/app_router.rb', line 35
def self.http_verbs
@http_verbs||=["GET", "POST", "PUT", "DELETE", "HEAD"]
end
|
.options(opt) ⇒ Object
30
31
32
33
|
# 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) ⇒ Object
55
56
57
|
# File 'lib/phantom_proxy/router/app_router.rb', line 55
def self.print_ram_usage(text)
end
|
Instance Method Details
#next_api ⇒ Object
14
15
16
|
# File 'lib/phantom_proxy/router/app_router.rb', line 14
def next_api
Http.NextApi
end
|
#render(template_name, status_code = 200, bind = nil) ⇒ Object
22
23
24
25
26
27
28
|
# 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 ⇒ Object
18
19
20
|
# File 'lib/phantom_proxy/router/app_router.rb', line 18
def renderer
@@renderer||=TemplateRenderer.create(binding)
end
|