Module: Billy::Handler
- Included in:
- CacheHandler, ProxyHandler, RequestHandler, StubHandler
- Defined in:
- lib/billy/handlers/handler.rb
Instance Method Summary collapse
-
#handle_request(_http_method, _url, _headers, _body) ⇒ Hash
Handles an incoming HTTP request and returns a response.
-
#handles_request?(_http_method, _url, _headers, _body) ⇒ Boolean
Checks if the Handler can respond to the given request.
-
#reset ⇒ Object
Resets the Handler to the default/new state.
Instance Method Details
#handle_request(_http_method, _url, _headers, _body) ⇒ Hash
Handles an incoming HTTP request and returns a response.
This method accepts HTTP request parameters and must return a response hash containing the keys :status, :headers, and :content, or nil if the request cannot be fulfilled.
18 19 20 |
# File 'lib/billy/handlers/handler.rb', line 18 def handle_request(_http_method, _url, _headers, _body) { error: 'The handler has not overridden the handle_request method!' } end |
#handles_request?(_http_method, _url, _headers, _body) ⇒ Boolean
Checks if the Handler can respond to the given request.
32 33 34 |
# File 'lib/billy/handlers/handler.rb', line 32 def handles_request?(_http_method, _url, _headers, _body) false end |
#reset ⇒ Object
Resets the Handler to the default/new state
This allows the handler to be set back to its default state at the end of tests or whenever else necessary.
43 |
# File 'lib/billy/handlers/handler.rb', line 43 def reset; end |