Start working with Rack
This commit is contained in:
parent
50b59b0d2f
commit
d15a0c92ca
2 changed files with 31 additions and 0 deletions
14
lib/sapling/middleware.rb
Normal file
14
lib/sapling/middleware.rb
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
require_relative './gardner'
|
||||||
|
|
||||||
|
class Middle
|
||||||
|
attr_reader :tree
|
||||||
|
|
||||||
|
def initialize(app)
|
||||||
|
@app = app
|
||||||
|
@tree = Gardner::Plot.new(YAML.load_file('lib/sapling/example.yaml'))
|
||||||
|
end
|
||||||
|
|
||||||
|
def call(env)
|
||||||
|
@app.call(env)
|
||||||
|
end
|
||||||
|
end
|
17
lib/sapling/server.ru
Normal file
17
lib/sapling/server.ru
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
require 'erb'
|
||||||
|
|
||||||
|
require_relative './gardner'
|
||||||
|
|
||||||
|
# Rack Stuff
|
||||||
|
class Greenhouse
|
||||||
|
|
||||||
|
def initialize
|
||||||
|
@response = ERB.new(File.read('lib/sapling/index.erb')).result(binding)
|
||||||
|
end
|
||||||
|
|
||||||
|
def call(_env)
|
||||||
|
['200', { 'Content-Type' => 'text/html' }, [@response]]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
run Greenhouse.new
|
Loading…
Reference in a new issue