From d5382e158f78d2299e9a703db039214115145014 Mon Sep 17 00:00:00 2001 From: 0x1eef <0x1eef@protonmail.com> Date: Thu, 29 Jun 2023 12:45:48 -0300 Subject: [PATCH] Assign `@mime_types` --- packages/ruby/server/lib/server/dir.rb | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/packages/ruby/server/lib/server/dir.rb b/packages/ruby/server/lib/server/dir.rb index cb1fe20..0cacd0a 100644 --- a/packages/ruby/server/lib/server/dir.rb +++ b/packages/ruby/server/lib/server/dir.rb @@ -8,6 +8,7 @@ class Server::Dir def initialize(root) @root = File.realpath(root) + @mime_types = {".ttf" => "font/ttf"}.freeze end def call(env) @@ -23,10 +24,6 @@ class Server::Dir [500, {"content-length" => body.bytesize, "content-type" => "text/plain"}, [body]] end - private - - attr_reader :root - def finish(request) path = find_path(request) body = File.binread(path) @@ -39,12 +36,12 @@ class Server::Dir ] end + private + + attr_reader :root, :mime_types + def find_path(request) path = File.join root, File.expand_path(request.path) File.directory?(path) ? File.join(path, "index.html") : path end - - def mime_types - {".ttf" => "font/ttf"}.freeze - end end