URI proxying support

This commit is contained in:
maddiebaka
2023-08-04 21:49:40 -04:00
parent 4d0f9802fc
commit a68a88bd1a
6 changed files with 59 additions and 56 deletions

View File

@@ -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