Module: PhantomProxy::Http
- Defined in:
- lib/phantom_proxy/helper/http.rb
Class Method Summary collapse
- .error_massages ⇒ Object
- .error_object_binding(obj) ⇒ Object
- .NextApi(data = "Not Found", content_type = "text/plain") ⇒ Object
- .OK(data = "", content_type = "text/plain") ⇒ Object
- .OK_no_data(data = "", content_type = "text/plain") ⇒ Object
- .renderer ⇒ Object
- .Response(status_code = 200, data = "", content_type = "text/plain") ⇒ Object
Class Method Details
.error_massages ⇒ Object
23 24 25 |
# File 'lib/phantom_proxy/helper/http.rb', line 23 def self.error_massages @error_massages||={"Not Found" => 404, "Server Error" => 500, "Not Allowed" => 403, "Not Authorized" => 401} end |
.error_object_binding(obj) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/phantom_proxy/helper/http.rb', line 6 def self.error_object_binding(obj) obj||={} def obj.get_binding binding end def obj.title self[:title] end def obj.content self[:content] end def obj.error_code self[:error_code] end obj.get_binding end |
.NextApi(data = "Not Found", content_type = "text/plain") ⇒ Object
33 34 35 |
# File 'lib/phantom_proxy/helper/http.rb', line 33 def self.NextApi(data="Not Found", content_type="text/plain") Response(600, data, content_type) end |
.OK(data = "", content_type = "text/plain") ⇒ Object
36 37 38 |
# File 'lib/phantom_proxy/helper/http.rb', line 36 def self.OK(data="", content_type="text/plain") Response(200, data, content_type) end |
.OK_no_data(data = "", content_type = "text/plain") ⇒ Object
42 43 44 |
# File 'lib/phantom_proxy/helper/http.rb', line 42 def self.OK_no_data(data="", content_type="text/plain") [204, {}, ""] end |
.renderer ⇒ Object
3 4 5 |
# File 'lib/phantom_proxy/helper/http.rb', line 3 def self.renderer @@renderer||=TemplateRenderer.create(binding) end |
.Response(status_code = 200, data = "", content_type = "text/plain") ⇒ Object
39 40 41 |
# File 'lib/phantom_proxy/helper/http.rb', line 39 def self.Response(status_code=200, data="", content_type="text/plain") [status_code, {"Content-Type" => content_type}, data] end |