Class: WebSystem::RequestCommand
- Inherits:
-
DevSystem::Command
- Object
- Liza::Unit
- Liza::Controller
- DevSystem::Command
- WebSystem::RequestCommand
- Defined in:
- lib/web_system/sub/request/commands/request_command.rb
Class Method Summary collapse
- .call(args) ⇒ Object
- .get(args) ⇒ Object
-
.get_command_signatures ⇒ Object
TODO: fix this.
- .help(args) ⇒ Object
- .post(args) ⇒ Object
Instance Method Summary collapse
-
#request_panel ⇒ Object
helpers.
Methods inherited from DevSystem::Command
Methods inherited from Liza::Controller
color, inherited, on_connected
Methods inherited from Liza::Unit
const_missing, division, part, system, #system, test_class
Class Method Details
.call(args) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/web_system/sub/request/commands/request_command.rb', line 3 def self.call(args) log "args = #{args.inspect}" path, qs = args.first.split("?") help(args) # always show help new.instance_exec do @env = {} @env["PATH_INFO"] = path @env["QUERY_STRING"] = qs request_panel.find @env @request_class = @env["LIZA_REQUEST_CLASS"] || raise("No request class found") puts render :find, format: :txt end end |
.get(args) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/web_system/sub/request/commands/request_command.rb', line 30 def self.get(args) return superclass.method(__method__).call(args) unless args.is_a? Array log "args = #{args.inspect}" path, qs = args.first.split("?") return help if path.nil? new.instance_exec do @env = {} @env["REQUEST_METHOD"] = "GET" @env["PATH_INFO"] = path @env["QUERY_STRING"] = qs @status, @headers, @body = request_panel.call! @env log "STATUS #{@status} with #{@headers.count} headers and a #{@body.first.size} byte body" puts render :response, format: :http end end |
.get_command_signatures ⇒ Object
TODO: fix this
73 74 75 |
# File 'lib/web_system/sub/request/commands/request_command.rb', line 73 def self.get_command_signatures super << OpenStruct.new({name: "get", description: "# no description"}) end |
.help(args) ⇒ Object
23 24 25 26 27 28 |
# File 'lib/web_system/sub/request/commands/request_command.rb', line 23 def self.help(args) log "args = #{args.inspect}" new.instance_exec do puts render :help, format: :txt end end |
.post(args) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/web_system/sub/request/commands/request_command.rb', line 48 def self.post(args) return superclass.method(__method__).call(args) unless args.is_a? Array log "args = #{args.inspect}" path, qs = args.first.split("?") return help if path.nil? new.instance_exec do @env = {} @env["REQUEST_METHOD"] = "POST" @env["PATH_INFO"] = path @env["QUERY_STRING"] = qs @status, @headers, @body = request_panel.call! @env log "STATUS #{@status} with #{@headers.count} headers and a #{@body.first.size} byte body" puts render :response, format: :http end end |
Instance Method Details
#request_panel ⇒ Object
helpers
68 69 70 |
# File 'lib/web_system/sub/request/commands/request_command.rb', line 68 def request_panel @request_panel ||= WebBox[:request] end |