Sha256: e8928859fa877a8b742b092a17c0515218d799f95adb964940fc116ee27c5da8
Contents?: true
Size: 839 Bytes
Versions: 4
Compression:
Stored size: 839 Bytes
Contents
require 'erb' require 'pathname' require 'hanami/environment' require 'hanami/utils/string' module Hanami class Welcome def initialize(_app) @root = Pathname.new(__dir__).join('templates').realpath end def call(env) @request_path = env['REQUEST_PATH'] || '' @body = [ERB.new(@root.join('welcome.html.erb').read).result(binding)] [200, {}, @body] end def application_name " #{ app }" if container? end private def container? Environment.new.container? end def application_class applications = Hanami::Application.applications.to_a applications.select do |app| @request_path.include? app.configuration.path_prefix.to_s end.first end def app Utils::String.new(application_class).namespace.downcase end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
hanami-0.8.0 | lib/hanami/welcome.rb |
hanami-0.7.3 | lib/hanami/welcome.rb |
hanami-0.7.2 | lib/hanami/welcome.rb |
hanami-0.7.1 | lib/hanami/welcome.rb |