github.com/turtlemonvh/terraform@v0.6.9-0.20151204001754-8e40b6b855e8/website/config.ru (about)

     1  require "rack"
     2  require "rack/contrib/not_found"
     3  require "rack/contrib/response_headers"
     4  require "rack/contrib/static_cache"
     5  require "rack/contrib/try_static"
     6  require "rack/protection"
     7  
     8  # Protect against various bad things
     9  use Rack::Protection::JsonCsrf
    10  use Rack::Protection::RemoteReferrer
    11  use Rack::Protection::HttpOrigin
    12  use Rack::Protection::EscapedParams
    13  use Rack::Protection::XSSHeader
    14  use Rack::Protection::FrameOptions
    15  use Rack::Protection::PathTraversal
    16  use Rack::Protection::IPSpoofing
    17  
    18  # Properly compress the output if the client can handle it.
    19  use Rack::Deflater
    20  
    21  # Set the "forever expire" cache headers for these static assets. Since
    22  # we hash the contents of the assets to determine filenames, this is safe
    23  # to do.
    24  use Rack::StaticCache,
    25    :root => "build",
    26    :urls => ["/images", "/javascripts", "/stylesheets"],
    27    :duration => 2,
    28    :versioning => false
    29  
    30  # Try to find a static file that matches our request, since Middleman
    31  # statically generates everything.
    32  use Rack::TryStatic,
    33    :root => "build",
    34    :urls => ["/"],
    35    :try  => [".html", "index.html", "/index.html"]
    36  
    37  # 404 if we reached this point. Sad times.
    38  run Rack::NotFound.new(File.expand_path("../build/404.html", __FILE__))