Class: Simple::Httpd::Rack::DynamicMount

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Simple::Httpd::RouteDescriptions
Defined in:
lib/simple/httpd/rack/dynamic_mount.rb

Overview

The Simple::Httpd::Mountpoint.build returns a Rack compatible app, which serves HTTP requests according to a set of dynamic ruby scripts and some existing static files.

Constant Summary collapse

H =
::Simple::Httpd::Helpers
Rack =
::Simple::Httpd::Rack

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Simple::Httpd::RouteDescriptions

#describe_route!, #route_descriptions

Constructor Details

#initialize(mount_point, path) ⇒ DynamicMount

Returns a new instance of DynamicMount.



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/simple/httpd/rack/dynamic_mount.rb', line 22

def initialize(mount_point, path)
  @mount_point = mount_point
  @path = path.gsub(/\/\z/, "") # remove trailing "/"

  setup_paths!
  load_service_files!
  @root_controller = build_root_controller # also loads helpers
  @url_map = build_url_map

  @rack_app = ::Rack::URLMap.new(@url_map)
end

Instance Attribute Details

#mount_pointObject (readonly)

Returns the value of attribute mount_point.



20
21
22
# File 'lib/simple/httpd/rack/dynamic_mount.rb', line 20

def mount_point
  @mount_point
end

#pathObject (readonly)

Returns the value of attribute path.



19
20
21
# File 'lib/simple/httpd/rack/dynamic_mount.rb', line 19

def path
  @path
end

Class Method Details

.build(mount_point, path) ⇒ Object



14
15
16
17
# File 'lib/simple/httpd/rack/dynamic_mount.rb', line 14

def self.build(mount_point, path)
  expect! path => String
  new(mount_point, path)
end