Skip to content

Instantly share code, notes, and snippets.

@jpfuentes2
Last active December 15, 2015 10:39
Show Gist options
  • Save jpfuentes2/5247504 to your computer and use it in GitHub Desktop.
Save jpfuentes2/5247504 to your computer and use it in GitHub Desktop.
require 'rack'
require 'sinatra/base'
class App < Sinatra::Base
use Rack::Static, :urls => ["/js"], :root => '.'
not_found do
halt 404, "nawp"
end
error 404 do
halt 404, "nawp"
end
error do
halt 404, "nawp"
end
end
code λ curl -v localhost:9292/js/not-found.js
* About to connect() to localhost port 9292 (#0)
* Trying ::1...
* Connection refused
* Trying 127.0.0.1...
* connected
* Connected to localhost (127.0.0.1) port 9292 (#0)
> GET /js/not-found.js HTTP/1.1
> User-Agent: curl/7.24.0 (x86_64-apple-darwin12.0) libcurl/7.24.0 OpenSSL/0.9.8r zlib/1.2.5
> Host: localhost:9292
> Accept: */*
>
< HTTP/1.1 404 Not Found
< Content-Type: text/plain
< Content-Length: 33
< X-Cascade: pass
< X-Content-Type-Options: nosniff
< Connection: keep-alive
< Server: thin 1.5.0 codename Knife
<
File not found: /js/not-found.js
* Connection #0 to host localhost left intact
* Closing connection #0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment