Added static file serving from public/.
This commit is contained in:
parent
614e73bad1
commit
9b8f2368fd
16
stoptime.rb
16
stoptime.rb
|
@ -13,6 +13,7 @@
|
|||
require "active_support"
|
||||
require "camping"
|
||||
require "markaby"
|
||||
require "mime/types"
|
||||
require "pathname"
|
||||
|
||||
Markaby::Builder.set(:indent, 2)
|
||||
|
@ -254,7 +255,20 @@ module StopTime::Controllers
|
|||
render :invoices
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
class StaticX
|
||||
def get(path)
|
||||
mime_type = MIME::Types.type_for(path).first
|
||||
@headers['Content-Type'] = mime_type.nil? ? "text/plain" : mime_type.to_s
|
||||
unless path.include? ".."
|
||||
@headers['X-Sendfile'] = (BASE_DIR + path).to_s
|
||||
else
|
||||
@status = "403"
|
||||
"Error 403: Invalid path: #{path}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end # module StopTime::Controllers
|
||||
|
||||
module StopTime::Views
|
||||
|
|
Loading…
Reference in New Issue