aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Duncan <pabs@pablotron.org>2016-07-16 21:24:00 -0400
committerPaul Duncan <pabs@pablotron.org>2016-07-16 21:24:00 -0400
commit78bc82bd95889af8c0cba152b8a0956b29b44e7b (patch)
treefc0cfd4a5c77dcd03bfa6228a66bafecd6464704
parentd1cbae09bf46999e023a7dd2291a534b9737c804 (diff)
downloadguff-78bc82bd95889af8c0cba152b8a0956b29b44e7b.tar.bz2
guff-78bc82bd95889af8c0cba152b8a0956b29b44e7b.zip
remove debug code and cache magic db reference
-rw-r--r--src/guff/handlers.cr12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/guff/handlers.cr b/src/guff/handlers.cr
index b0fc09a..51be36e 100644
--- a/src/guff/handlers.cr
+++ b/src/guff/handlers.cr
@@ -170,9 +170,7 @@ module Guff::Handlers
if context.request.method == "GET"
# send body for GET requests
File.open(abs_path) do |fh|
- STDERR.puts "sending #{abs_path}"
IO.copy(fh, context.response)
- STDERR.puts "done sending #{abs_path}"
end
end
end
@@ -548,6 +546,11 @@ module Guff::Handlers
# FIXME: this is very similar to AssetsHandler, so maybe combine them?
class FilesHandler < Handler
+ def initialize(context : Context)
+ super(context)
+ @magic = Magic.new
+ end
+
def call(context : HTTP::Server::Context)
req_path = context.request.path.not_nil!
@@ -625,10 +628,7 @@ module Guff::Handlers
end
private def get_mime_type(path : String) : String
- puts "DEBUG: getting mime type"
- r = Guff::Magic.get_mime_type(path)
- puts "DEBUG: mime type = #{r}"
- r
+ @magic.file(path)
end
end