Class: Volt::HttpController
- Includes:
- LifecycleCallbacks
- Defined in:
- lib/volt/controllers/http_controller.rb
Overview
Allow you to create controllers that act as http endpoints
Instance Method Summary collapse
- #cookies ⇒ Object
-
#initialize(volt_app, params, request) ⇒ HttpController
constructor
Initialzed with the params parsed from the route and the HttpRequest.
- #params ⇒ Object
- #perform(action = 'index') ⇒ Object
Methods included from LifecycleCallbacks
included, #run_callbacks, #stop_chain
Constructor Details
#initialize(volt_app, params, request) ⇒ HttpController
Initialzed with the params parsed from the route and the HttpRequest
14 15 16 17 18 19 20 |
# File 'lib/volt/controllers/http_controller.rb', line 14 def initialize(volt_app, params, request) @volt_app = volt_app @response_headers = HttpResponseHeader.new @response_body = [] @request = request @initial_params = params end |
Instance Method Details
#cookies ⇒ Object
29 30 31 |
# File 'lib/volt/controllers/http_controller.rb', line 29 def @cookies ||= Volt::Model.new(request., persistor: Volt::Persistors::HttpCookiePersistor) end |
#params ⇒ Object
22 23 24 25 26 27 |
# File 'lib/volt/controllers/http_controller.rb', line 22 def params @params ||= begin params = request.params.symbolize_keys.merge(@initial_params) Volt::Model.new(params, persistor: Volt::Persistors::Params) end end |
#perform(action = 'index') ⇒ Object
33 34 35 36 37 38 |
# File 'lib/volt/controllers/http_controller.rb', line 33 def perform(action='index') filtered = run_callbacks(:before_action, action) send(action.to_sym) unless filtered run_callbacks(:after_action, action) unless filtered respond end |