Class: OodAppkit::FilesRackApp

Inherits:
Object
  • Object
show all
Defined in:
lib/ood_appkit/files_rack_app.rb

Overview

Middleware that serves entries below the ‘root` given, according to the path info of the Rack request.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(root: OodAppkit.dataroot) ⇒ FilesRackApp

Returns a new instance of FilesRackApp.

Parameters:

  • root (String, #to_s) (defaults to: OodAppkit.dataroot)

    the root path



11
12
13
# File 'lib/ood_appkit/files_rack_app.rb', line 11

def initialize(root: OodAppkit.dataroot)
  @root = root.to_s
end

Instance Attribute Details

#rootString

The root path on file system that this app serves entries from below

Returns:

  • (String)

    the root path



8
9
10
# File 'lib/ood_appkit/files_rack_app.rb', line 8

def root
  @root
end

Instance Method Details

#call(env) ⇒ Object

Use ‘Rack::Directory` as middleware with `root` set as `dataroot` by default



17
18
19
# File 'lib/ood_appkit/files_rack_app.rb', line 17

def call(env)
  Rack::Directory.new(root).call(env)
end