Class: IrcMachine::HttpController
- Inherits:
-
Object
- Object
- IrcMachine::HttpController
- Defined in:
- lib/irc_machine/http_controller.rb
Direct Known Subclasses
Controller::ChannelsController, Controller::GithubNotificationsController
Instance Attribute Summary collapse
-
#match ⇒ Object
readonly
Returns the value of attribute match.
-
#request ⇒ Object
readonly
Returns the value of attribute request.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
-
#session ⇒ Object
readonly
Returns the value of attribute session.
Class Method Summary collapse
Instance Method Summary collapse
- #content_type(type) ⇒ Object
-
#initialize(session, request, match) ⇒ HttpController
constructor
A new instance of HttpController.
- #not_found ⇒ Object
- #ok(content) ⇒ Object
Constructor Details
#initialize(session, request, match) ⇒ HttpController
Returns a new instance of HttpController.
10 11 12 13 14 15 |
# File 'lib/irc_machine/http_controller.rb', line 10 def initialize(session, request, match) @session = session @request = request @match = match @response = Rack::Response.new end |
Instance Attribute Details
#match ⇒ Object (readonly)
Returns the value of attribute match.
19 20 21 |
# File 'lib/irc_machine/http_controller.rb', line 19 def match @match end |
#request ⇒ Object (readonly)
Returns the value of attribute request.
18 19 20 |
# File 'lib/irc_machine/http_controller.rb', line 18 def request @request end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
18 19 20 |
# File 'lib/irc_machine/http_controller.rb', line 18 def response @response end |
#session ⇒ Object (readonly)
Returns the value of attribute session.
17 18 19 |
# File 'lib/irc_machine/http_controller.rb', line 17 def session @session end |
Class Method Details
.dispatch(session, request, method, match) ⇒ Object
4 5 6 7 8 |
# File 'lib/irc_machine/http_controller.rb', line 4 def self.dispatch(session, request, method, match) new(session, request, match).tap do |c| c.send method end.response end |
Instance Method Details
#content_type(type) ⇒ Object
30 31 32 |
# File 'lib/irc_machine/http_controller.rb', line 30 def content_type(type) @response["Content-Type"] = type end |
#not_found ⇒ Object
26 27 28 |
# File 'lib/irc_machine/http_controller.rb', line 26 def not_found @response.status = 404 end |
#ok(content) ⇒ Object
21 22 23 24 |
# File 'lib/irc_machine/http_controller.rb', line 21 def ok(content) @response.status = 200 @response.write content end |