-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.ru
More file actions
32 lines (30 loc) · 693 Bytes
/
config.ru
File metadata and controls
32 lines (30 loc) · 693 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#\ -p 8000
class RackHack
def call(env)
[200, {"Content-Type" => "text/html"}, ["<h2>Hello #{wish(env)}</h2>"]]
end
def wish(env)
path = env['REQUEST_PATH']
if path =~ /^\/$/
return "World!"
else
return path.split('/')[1]
end
end
end
class Styles
def initialize(resp)
@resp = resp
end
def call(env)
status, headers, body = @resp.call(env)
body = add_styles(body)
[status, headers, body]
end
def add_styles(body)
style_container = "<style> h2{border 3px solid green; width: 100%; background: crimson; color:white} </style>"
body.map{ |b| "<body>#{style_container} #{b} </body>" }
end
end
use Styles
run RackHack.new