Class: YARD::Server::RackAdapter
- Includes:
- WEBrick::HTTPUtils
- Defined in:
- lib/yard/server/rack_adapter.rb
Overview
A server adapter to respond to requests using the Rack server infrastructure.
Instance Attribute Summary collapse
-
#document_root ⇒ String
inherited
from Adapter
The location where static files are located, if any.
-
#libraries ⇒ Hash{String=>Array<LibraryVersion>}
inherited
from Adapter
A map of libraries.
-
#options ⇒ Hash
inherited
from Adapter
Options passed and processed by adapters.
-
#router ⇒ Router
inherited
from Adapter
The router object used to route URLs to commands.
-
#server_options ⇒ Hash
inherited
from Adapter
A set of options to pass to the server backend.
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
.
Constructor Details
This class inherits a constructor from YARD::Server::Adapter
Instance Attribute Details
#document_root ⇒ String Originally defined in class Adapter
Returns the location where static files are located, if any. To set this
field on initialization, pass :DocumentRoot
to the
server_opts
argument in #initialize
#libraries ⇒ Hash{String=>Array<LibraryVersion>} Originally defined in class Adapter
Returns a map of libraries.
#options ⇒ Hash Originally defined in class Adapter
Returns options passed and processed by adapters. The actual options mostly depend on the adapters themselves.
#router ⇒ Router Originally defined in class Adapter
Returns the router object used to route URLs to commands
#server_options ⇒ Hash Originally defined in class Adapter
Returns a set of options to pass to the server backend. Note that
:DocumentRoot
also sets the #document_root.
Instance Method Details
#call(env) ⇒ Array(Numeric,Hash,Array)
Responds to Rack requests and builds a response with the YARD::Server::Router.
48 49 50 51 52 53 54 55 56 |
# File 'lib/yard/server/rack_adapter.rb', line 48 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.
61 62 63 64 65 66 |
# File 'lib/yard/server/rack_adapter.rb', line 61 def start server = Rack::Server.new() server.instance_variable_set("@app", self) (server) server.start end |