Class: Hyde::Server
Overview
A specialized path that can be used directly as a Rack application.
Constant Summary collapse
- Context =
ServerContext
Constants inherited from Path
Instance Attribute Summary
Attributes inherited from Path
Attributes inherited from Node
Instance Method Summary collapse
-
#call(env) ⇒ Array(Integer,Hash,Array)
Rack ingress point.
-
#initialize(parent: nil, &setup) ⇒ Server
constructor
A new instance of Server.
Methods inherited from Path
#filter, #postprocess, #preprocess, #process
Methods inherited from Node
Constructor Details
#initialize(parent: nil, &setup) ⇒ Server
Returns a new instance of Server.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/hyde/server.rb', line 17 def initialize(parent: nil, &setup) super("", parent: parent, &setup) return if parent { "index" => [], "handle.default" => proc do |code, backtrace: nil| page = Hyde::Util.default_error_page(code, backtrace) headers = { "content-length": page.bytesize, "content-type": "text/html" } [headers, page] end, "path" => "/" }.each { |k, v| @properties[k] = v unless @properties[k] } end |
Instance Method Details
#call(env) ⇒ Array(Integer,Hash,Array)
Rack ingress point. This should not be called under any circumstances twice in the same application, although server nesting for the purpose of creating virtual hosts is allowed.
40 41 42 43 44 45 46 47 |
# File 'lib/hyde/server.rb', line 40 def call(env) request = Hyde::Request.new(env) response = catch(:finish) do go(request) end request.run_postprocessors(response) Response.convert(response).finalize end |