Class: Flon::API
- Inherits:
-
Object
- Object
- Flon::API
- Defined in:
- lib/flon/api.rb
Overview
This class is Flon’s Rack application.
Instance Method Summary collapse
-
#call(env) ⇒ Array
Implements the Rack interface.
-
#initialize(api) ⇒ API
constructor
Creates a new API object with the given API.
Constructor Details
Instance Method Details
#call(env) ⇒ Array
Implements the Rack interface.
93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/flon/api.rb', line 93 def call(env) request = Rack::Request.new(env) method = http_method_to_symbol(request.request_method) path = request.path_info response = case (match = @router.match(method, path)) when :bad_path then Response.new(404, '"404 Not Found"') when :bad_method then Response.new(405, '"405 Method Not Allowed"') else dispatch(method, request, match) end rack_response(method, response) end |