- formating

This commit is contained in:
Alex Ling
2020-02-16 16:53:20 +00:00
parent 7c66b05872
commit 713694fd85
4 changed files with 5 additions and 7 deletions
+29
View File
@@ -0,0 +1,29 @@
require "baked_file_system"
require "kemal"
require "gzip"
require "./util"
class FS
extend BakedFileSystem
bake_folder "../public"
end
class StaticHandler < Kemal::Handler
property dirs : Array(String)
def initialize
@dirs = ["/css", "/js"]
end
def call(env)
if request_path_startswith env, @dirs
file = FS.get? env.request.path
return call_next env if file.nil?
slice = Bytes.new file.size
file.read slice
return send_file env, slice, file.mime_type
end
call_next env
end
end