Class: RootRequest
- Inherits:
-
AppRequest
- Object
- Liza::Unit
- Liza::Controller
- WebSystem::Request
- AppRequest
- RootRequest
- Defined in:
- app/web/requests/root_request.rb
Class Method Summary collapse
-
.call(env) ⇒ Object
NOTE: There’s a bug in this file.
- .render_action_index ⇒ Object
- .render_action_not_found(action) ⇒ Object
Methods inherited from Liza::Controller
color, inherited, on_connected
Methods inherited from Liza::Unit
const_missing, division, part, system, #system, test_class
Class Method Details
.call(env) ⇒ Object
NOTE: There’s a bug in this file. Can you find it?
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'app/web/requests/root_request.rb', line 4 def self.call env action = env["LIZA_ACTION"] # @status = 200 @headers = { "Framework" => "Liza #{Lizarb::VERSION}" } @body = "" if action == "index" render_action_index else @status = 404 render_action_not_found action end [@status, @headers, [@body]] rescue => e @status = 500 @body = "#{e.class} - #{e.}" log @status [@status, @headers, [@body]] end |
.render_action_index ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'app/web/requests/root_request.rb', line 33 def self.render_action_index h1 = "Ruby Works!" @body = <<~CODE <html> <head> <title>Ruby</title> <link rel="stylesheet" href="/assets/app.css" /> <script type="application/javascript" src="/assets/app.js"></script> </head> <body> <h1>#{h1}</h1> </body> </html> CODE end |
.render_action_not_found(action) ⇒ Object
50 51 52 |
# File 'app/web/requests/root_request.rb', line 50 def self.render_action_not_found action @body = "Ruby couldn't find your page! action: #{action}" end |