Class: Fastr::Controller
- Inherits:
-
Object
- Object
- Fastr::Controller
- Includes:
- Async, Cookie, Deferrable, Filter, Template
- Defined in:
- lib/fastr/controller.rb
Overview
All controllers in a Fastr application should inherit from this class.
Sample Controller
class HomeController < Fastr::Controller
def index
[200, {"Content-Type" => "text/plain"}, ["Hello, World!"]]
end
end
Response headers
You can add response headers directly by accessing the instance attribute #headers.
self.headers['My-Header'] = 'value'
Cookies
You can access cookies in the request by accessing the instance attribute #cookies.
self.['MYCOOKIE']
Params
You can access the parameters in the request by accessing the instance attribute #params.
self.params['paramSentInRequest']
Constant Summary
Constants included from Template
Template::EXTENSIONS, Template::TEMPLATE_CACHE
Instance Attribute Summary collapse
-
#app ⇒ Fastr::Application
The application for the controller’s current request.
-
#cookies ⇒ Hash
Cookies sent in the request.
-
#env ⇒ Hash
The current Rack environment for the request.
-
#get_params ⇒ Hash
GET parameters.
-
#headers ⇒ Hash
Headers to send in the response.
-
#params ⇒ Hash
The params for this request.
-
#post_params ⇒ Hash
POST parameters.
Class Method Summary collapse
Methods included from Async
Methods included from Filter
execute_filter, #filter_continue, #filter_stop, get_filters, get_filters_for_action, included, run_after_filters, run_before_filters, run_filter?
Methods included from Log
create_logger, included, level=
Methods included from Cookie
Methods included from Deferrable
Methods included from Template
#engine_for, included, register_extensions, #render, #render_json, #render_template, #render_template_to_string, #render_text, #template_extensions
Instance Attribute Details
#app ⇒ Fastr::Application
The application for the controller’s current request.
46 47 48 |
# File 'lib/fastr/controller.rb', line 46 def app @app end |
#cookies ⇒ Hash
Cookies sent in the request
56 57 58 |
# File 'lib/fastr/controller.rb', line 56 def @cookies end |
#env ⇒ Hash
The current Rack environment for the request.
36 37 38 |
# File 'lib/fastr/controller.rb', line 36 def env @env end |
#get_params ⇒ Hash
GET parameters.
61 62 63 |
# File 'lib/fastr/controller.rb', line 61 def get_params @get_params end |
#headers ⇒ Hash
Headers to send in the response.
51 52 53 |
# File 'lib/fastr/controller.rb', line 51 def headers @headers end |
#params ⇒ Hash
The params for this request.
41 42 43 |
# File 'lib/fastr/controller.rb', line 41 def params @params end |
#post_params ⇒ Hash
POST parameters.
66 67 68 |
# File 'lib/fastr/controller.rb', line 66 def post_params @post_params end |
Class Method Details
.inherited(kls) ⇒ Object
74 75 76 |
# File 'lib/fastr/controller.rb', line 74 def self.inherited(kls) kls.instance_eval('include Fastr::Log') end |