Class: YARD::Server::RackAdapter

Inherits:
Adapter
  • Object
show all
Includes:
HTTPUtils
Defined in:
lib/yard/server/rack_adapter.rb

Overview

A server adapter to respond to requests using the Rack server infrastructure.

Since:

  • 0.6.0

Constant Summary

Constants included from HTTPUtils

HTTPUtils::DefaultMimeTypes, HTTPUtils::ESCAPED, HTTPUtils::NONASCII, HTTPUtils::UNESCAPED, HTTPUtils::UNESCAPED_FORM, HTTPUtils::UNESCAPED_PCHAR

Instance Method Summary collapse

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.

Returns:

Since:

  • 0.6.0



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.message + "\n" + ex.backtrace.join("\n")]]
end

#startvoid

This method returns an undefined value.

Starts the Rack server. This method will pass control to the server and block.

Since:

  • 0.6.0



70
71
72
73
74
75
# File 'lib/yard/server/rack_adapter.rb', line 70

def start
  server = RackServer.new(server_options)
  server.instance_variable_set("@app", self)
  print_start_message(server)
  server.start
end