Class: HmlonsWeb::Controller
- Inherits:
-
Object
- Object
- HmlonsWeb::Controller
- Defined in:
- lib/hmlons_web/controller.rb
Constant Summary collapse
- RESPONSE_TYPES =
{ text: ['text/plain', ->(c) { c.to_s }], json: ['application/json', ->(c) { Oj.dump(c) }] }.freeze
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.action(action_name) ⇒ Object
15 16 17 |
# File 'lib/hmlons_web/controller.rb', line 15 def self.action(action_name) proc { |env| new(action_name).call(env) } end |
Instance Method Details
#call(env) ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/hmlons_web/controller.rb', line 7 def call(env) @env = env @request = Rack::Request.new(env) @request.params.merge!(env['router.params'] || {}) send(@action_name) [200, @response_headers, [@response_body]] end |