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]

ENV['JUNEBUG_ROOT'] || '.'

Instance Method Summary collapse

Instance Method Details

#get(path) ⇒ Object



138
139
140
141
142
143
144
145
# File 'lib/junebug/controllers.rb', line 138

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