Module: Mojito::Rendering::File

Defined in:
lib/mojito/rendering/file.rb

Defined Under Namespace

Classes: FileResponse

Instance Method Summary collapse

Instance Method Details

#file!(filename) ⇒ Object



11
12
13
14
15
16
17
18
19
20
# File 'lib/mojito/rendering/file.rb', line 11

def file!(filename)
	path = Where.cdir(1) + filename
	restrict_path! path if respond_to? :restrict_path!
	if path.readable? and path.file?
		body = FileResponse.new path
		halt! [response.status, response.headers.merge(body.compute_headers), body]
	else
		not_found!
	end
end