Class: YARD::Server::RackAdapter
- Includes:
- HTTPUtils
- Defined in:
- lib/yard/server/rack_adapter.rb
Overview
A server adapter to respond to requests using the Rack server infrastructure.
Constant Summary
Constants included from HTTPUtils
HTTPUtils::DefaultMimeTypes, HTTPUtils::ESCAPED, HTTPUtils::NONASCII, HTTPUtils::UNESCAPED, HTTPUtils::UNESCAPED_FORM, HTTPUtils::UNESCAPED_PCHAR
Instance Method Summary collapse
-
#call(env) ⇒ Array(Numeric,Hash,Array)
Responds to Rack requests and builds a response with the Router.
-
#start ⇒ void
Starts the Rack server.
Methods included from HTTPUtils
_escape, _make_regex, _make_regex!, _unescape, dequote, escape, escape8bit, escape_form, escape_path, load_mime_types, mime_type, normalize_path, parse_form_data, parse_header, parse_query, parse_qvalues, parse_range_header, quote, split_header_value, unescape, unescape_form
Constructor Details
This class inherits a constructor from YARD::Server::Adapter
Instance Method Details
#call(env) ⇒ Array(Numeric,Hash,Array)
Responds to Rack requests and builds a response with the YARD::Server::Router.
57 58 59 60 61 62 63 64 65 |
# File 'lib/yard/server/rack_adapter.rb', line 57 def call(env) request = Rack::Request.new(env) request.path_info = unescape(request.path_info) # unescape things like %3F router.call(request) rescue StandardError => ex log.backtrace(ex) [500, {'Content-Type' => 'text/plain'}, [ex. + "\n" + ex.backtrace.join("\n")]] end |
#start ⇒ void
This method returns an undefined value.
Starts the Rack server. This method will pass control to the server and block.
70 71 72 73 74 75 |
# File 'lib/yard/server/rack_adapter.rb', line 70 def start server = RackServer.new() server.instance_variable_set("@app", self) (server) server.start end |