Class: Kirei::Routing::Request

Inherits:
T::Struct
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/kirei/routing/request.rb

Instance Method Summary collapse

Instance Method Details

#domainObject



17
18
19
# File 'lib/kirei/routing/request.rb', line 17

def domain
  T.must(host.split(":").first).split(".").last(2).join(".")
end

#hostObject



12
13
14
# File 'lib/kirei/routing/request.rb', line 12

def host
  env.fetch("HTTP_HOST")
end

#portObject



30
31
32
# File 'lib/kirei/routing/request.rb', line 30

def port
  env.fetch("SERVER_PORT")&.to_i
end

#ssl?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/kirei/routing/request.rb', line 35

def ssl?
  env.fetch("HTTPS", env.fetch("rack.url_scheme", "http")) == "https"
end

#subdomainObject



22
23
24
25
26
27
# File 'lib/kirei/routing/request.rb', line 22

def subdomain
  parts = T.must(host.split(":").first).split(".")
  return if parts.size <= 2

  T.must(parts[0..-3]).join(".")
end