Class: Hanami::Web::Welcome Private

Inherits:
Object
  • Object
show all
Defined in:
lib/hanami/web/welcome.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Middleware that renders a welcome view in fresh Hanami apps.

Since:

  • 2.1.0

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Welcome

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Welcome.

Since:

  • 2.1.0



15
16
17
# File 'lib/hanami/web/welcome.rb', line 15

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 2.1.0



21
22
23
24
25
26
27
28
29
# File 'lib/hanami/web/welcome.rb', line 21

def call(env)
  request_path = env["REQUEST_PATH"] || ""
  request_host = env["HTTP_HOST"] || ""

  template_path = File.join(__dir__, "welcome.html.erb")
  body = [ERB.new(File.read(template_path)).result(binding)]

  [200, {}, body]
end