Class: Volt::HttpController
- Includes:
- LifecycleCallbacks, LoginAsHelper
- 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 LoginAsHelper
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
17 18 19 20 21 22 23 |
# File 'lib/volt/controllers/http_controller.rb', line 17 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
32 33 34 |
# File 'lib/volt/controllers/http_controller.rb', line 32 def @cookies ||= Volt::Model.new(request., persistor: Volt::Persistors::HttpCookiePersistor) end |
#params ⇒ Object
25 26 27 28 29 30 |
# File 'lib/volt/controllers/http_controller.rb', line 25 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
36 37 38 39 40 41 |
# File 'lib/volt/controllers/http_controller.rb', line 36 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 |