29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/linner/reactor.rb', line 29
def route_request(connection, request)
if request.url.start_with? "/livereload.js"
return connection.respond :ok, {"Content_Type" => 'application/ecmascript'}, File.read(File.join(File.dirname(__FILE__), "../../vendor", "livereload.js"))
end
path = File.join(Linner.environment.public_folder, request.url[1..-1])
if File.exist?(path)
content_type = case File.extname(path)
when '.css' then 'text/css'
when '.js' then 'application/ecmascript'
when '.gif' then 'image/gif'
when '.jpeg', '.jpg' then 'image/jpeg'
when '.png' then 'image/png'
else; 'text/plain'
end
return connection.respond :ok, {"Content_Type" => content_type, "Content_Length" => File.size(path)}, File.read(path)
end
connection.respond :not_found, "Not found"
end
|