Class: WebSystem::SimpleRequest

Inherits:
Request show all
Defined in:
lib/web_system/sub/request/requests/simple_request.rb

Direct Known Subclasses

FooRequest, LabSystem::KrokiRequest

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Liza::Controller

color, inherited, on_connected

Methods inherited from Liza::Unit

const_missing, division, part, system, #system, test_class

Instance Attribute Details

#envObject (readonly)

Returns the value of attribute env.



11
12
13
# File 'lib/web_system/sub/request/requests/simple_request.rb', line 11

def env
  @env
end

Class Method Details

.call(env) ⇒ Object



5
6
7
# File 'lib/web_system/sub/request/requests/simple_request.rb', line 5

def self.call env
  new.call env
end

Instance Method Details

#_call_actionObject



27
28
29
30
31
32
# File 'lib/web_system/sub/request/requests/simple_request.rb', line 27

def _call_action
  return public_send "call_#{action}!" if http_method == "POST" and respond_to? "call_#{action}!"
  return public_send "call_#{action}"  if respond_to? "call_#{action}"

  response_404
end

#actionObject



49
50
51
# File 'lib/web_system/sub/request/requests/simple_request.rb', line 49

def action
  @action ||= env["LIZA_ACTION"].to_sym
end

#call(env) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/web_system/sub/request/requests/simple_request.rb', line 13

def call env
  @env = env
  @status = 200
  @headers = {
    "Framework" => "Liza #{Lizarb::VERSION}"
  }

  _call_action
  @body ||= render format, action, format: format
  [@status, @headers, [@body]]
end

#formatObject



53
54
55
# File 'lib/web_system/sub/request/requests/simple_request.rb', line 53

def format
  @format ||= env["LIZA_FORMAT"].to_sym
end

#http_methodObject

env



41
42
43
# File 'lib/web_system/sub/request/requests/simple_request.rb', line 41

def http_method
  env["REQUEST_METHOD"]
end

#qsObject



61
62
63
# File 'lib/web_system/sub/request/requests/simple_request.rb', line 61

def qs
  @qs ||= (env["QUERY_STRING"] || "").split("&").map { _1.split("=") }.to_h
end

#requestObject



45
46
47
# File 'lib/web_system/sub/request/requests/simple_request.rb', line 45

def request
  @request ||= env["LIZA_REQUEST"].to_sym
end

#response_404Object



34
35
36
37
# File 'lib/web_system/sub/request/requests/simple_request.rb', line 34

def response_404
  @status = 404
  @body = "404"
end

#segmentsObject



57
58
59
# File 'lib/web_system/sub/request/requests/simple_request.rb', line 57

def segments
  @segments ||= env["LIZA_SEGMENTS"]
end