Class: Landline::Server

Inherits:
Path show all
Defined in:
lib/landline/server.rb

Overview

A specialized path that can be used directly as a Rack application.

Constant Summary collapse

Context =
ServerContext

Instance Attribute Summary

Attributes inherited from Path

#bounce, #children, #pipeline, #properties

Attributes inherited from Node

#remap, #root

Instance Method Summary collapse

Methods inherited from Path

#filter, #go, #postprocess, #preprocess, #process

Methods inherited from Node

#go, #process, #reject

Constructor Details

#initialize(passthrough = nil, parent: nil, **opts, &setup) ⇒ Server

Returns a new instance of Server.

Parameters:

  • parent (Landline::Node, nil) (defaults to: nil)

    Parent object to inherit properties to

  • setup (#call)

    Setup block



16
17
18
19
20
21
22
# File 'lib/landline/server.rb', line 16

def initialize(passthrough = nil, parent: nil, **opts, &setup)
  super("", parent: parent, **opts, &setup)
  return if parent

  @passthrough = passthrough
  setup_properties(parent: nil, **opts)
end

Instance Method Details

#call(env) ⇒ Array(Integer,Hash,Array)

Rack ingress point.

Parameters:

  • env (Hash)

Returns:

  • (Array(Integer,Hash,Array))


27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/landline/server.rb', line 27

def call(env)
  request = Landline::Request.new(env)

  response = handle_jumps(request)
  request.run_postprocessors(response)
  resp = response.finalize
  if resp[1][:"x-cascade"] and resp[0] == 404 and @passthrough
    @passthrough.call(request.env)
  else
    resp
  end
end