-
-
Notifications
You must be signed in to change notification settings - Fork 542
/
welcome.rb
46 lines (38 loc) · 876 Bytes
/
welcome.rb
1
2
3
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# frozen_string_literal: true
require "erb"
module Hanami
# @api private
module Web
# Middleware that renders a welcome view in fresh Hanami apps.
#
# @api private
# @since 2.1.0
class Welcome
# @api private
# @since 2.1.0
def initialize(app)
@app = app
end
# @api private
# @since 2.1.0
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
private
# @api private
# @since 2.1.0
def hanami_version
Hanami::VERSION
end
# @api private
# @since 2.1.0
def ruby_version
RUBY_DESCRIPTION
end
end
end
end