Class: YARD::Server::RackAdapter
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
Adapter
|
|
Instance Chain:
|
|
Inherits: |
YARD::Server::Adapter
|
Defined in: | lib/yard/server/rack_adapter.rb |
Overview
A server adapter to respond to requests using the Rack server infrastructure.
Constant Summary
HTTPUtils
- Included
DefaultMimeTypes, ESCAPED, NONASCII, UNESCAPED, UNESCAPED_FORM, UNESCAPED_PCHAR
Class Method Summary
Adapter
- Inherited
Instance Attribute Summary
Adapter
- Inherited
Instance Method Summary
-
#call(env) ⇒ Array(Numeric,Hash,Array)
Responds to Rack requests and builds a response with the
Router
. -
#start ⇒ void
Starts the Rack server.
- #print_start_message(server) private
HTTPUtils
- Included
#_escape, #_make_regex, #_make_regex!, #_unescape, | |
#dequote | Removes quotes and escapes from |
#escape | Escapes HTTP reserved and unwise characters in |
#escape8bit | Escapes 8 bit characters in |
#escape_form | Escapes form reserved characters in |
#escape_path | Escapes path |
#load_mime_types | Loads Apache-compatible mime.types in |
#mime_type | Returns the mime type of |
#normalize_path | Normalizes a request path. |
#parse_form_data | Parses form data in |
#parse_header | Parses an HTTP header |
#parse_query | Parses the query component of a URI in |
#parse_qvalues | Parses q values in |
#parse_range_header | Parses a Range header value |
#quote | Quotes and escapes quotes in |
#split_header_value | Splits a header value |
#unescape | Unescapes HTTP reserved and unwise characters in |
#unescape_form | Unescapes form reserved characters in |
Adapter
- Inherited
#add_library | Adds a library to the |
#start | Implement this method to connect your adapter to your server. |
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 Router
.
# 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
#print_start_message(server) (private)
# File 'lib/yard/server/rack_adapter.rb', line 79
def (server) opts = server. .merge(server. ) log.puts ">> YARD #{YARD::VERSION} documentation server at http://#{opts[:Host]}:#{opts[:Port]}" # Only happens for Mongrel return unless server.server.to_s == "Rack::Handler::Mongrel" log.puts ">> #{server.server.class_name} web server (running on Rack)" log.puts ">> Listening on #{opts[:Host]}:#{opts[:Port]}, CTRL+C to stop" end
#start ⇒ void
This method returns an undefined value.
Starts the Rack server. This method will pass control to the server and block.
# File 'lib/yard/server/rack_adapter.rb', line 70
def start server = RackServer.new( ) server.instance_variable_set("@app", self) (server) server.start end