Class: Junebug::Controllers::Static

Inherits:
R
  • Object
show all
Defined in:
lib/junebug/controllers.rb

Constant Summary collapse

MIME_TYPES =
{'.css' => 'text/css', '.js' => 'text/javascript', '.jpg' => 'image/jpeg'}
PATH =

PATH = __FILE__[/(.*)//, 1]

'.'

Instance Method Summary collapse

Instance Method Details

#get(path) ⇒ Object



130
131
132
133
134
135
136
137
# File 'lib/junebug/controllers.rb', line 130

def get(path)
  @headers['Content-Type'] = MIME_TYPES[path[/\.\w+$/, 0]] || "text/plain"
  unless path =~ /\.\./ # sample test to prevent directory traversal attacks
    @headers['X-Sendfile'] = "#{PATH}/static/#{path}"
  else
    "404 - Invalid path"
  end
end