URI proxying support
This commit is contained in:
18
config.ru
18
config.ru
@@ -3,26 +3,18 @@ require 'skeksis'
|
||||
SERVE_DIR="/Users/madeline/Code/gemini-bridge-rack/gemini"
|
||||
|
||||
class SkeksisApp
|
||||
def initialize
|
||||
@skeksis = Skeksis::GemBridge.new
|
||||
end
|
||||
|
||||
def call(env)
|
||||
status = 200
|
||||
headers = { "content-type" => "text/html" }
|
||||
#headers = {}
|
||||
body = resolve_path(SERVE_DIR + env['PATH_INFO'])
|
||||
body = @skeksis.query(SERVE_DIR + env['PATH_INFO'], env)
|
||||
|
||||
[status, headers, body]
|
||||
end
|
||||
|
||||
def resolve_path(path)
|
||||
if Dir.exist?(path)
|
||||
return Dir.each_child(path).map {|i| "#{i}\n"}
|
||||
elsif File.exist?(path)
|
||||
file = File.open(path, 'r')
|
||||
data = file.readlines
|
||||
[Skeksis.htmlize(data)]
|
||||
else # path is invalid
|
||||
return nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
run SkeksisApp.new
|
||||
|
||||
Reference in New Issue
Block a user