Sha256: 75fe06f140c1b20884de5937729469956cdfe549119674bba15b09d85bf4df5e

Contents?: true

Size: 953 Bytes

Versions: 4

Compression:

Stored size: 953 Bytes

Contents

class RootRequest < AppRequest

  # NOTE: There's a bug in this file. Can you find it?
  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.message}"

    log @status
    [@status, @headers, [@body]]
  end

  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

  def self.render_action_not_found action
    @body = "Ruby couldn't find your page! action: #{action}"
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
lizarb-1.0.5 app/web/requests/root_request.rb
lizarb-1.0.4 app/web/requests/root_request.rb
lizarb-1.0.3 app/web/requests/root_request.rb
lizarb-1.0.2 app/web/requests/root_request.rb