Skip to content

Instantly share code, notes, and snippets.

@thehenster
Created October 30, 2019 22:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thehenster/872db5a248daccee7c5106f6dd6a4ec4 to your computer and use it in GitHub Desktop.
Save thehenster/872db5a248daccee7c5106f6dd6a4ec4 to your computer and use it in GitHub Desktop.
Rackup file for dynamic requests, then static files, then not found
require 'rack'
require 'rack/static'
class App
def initialize(app)
@app = app
end
def call(env)
req = Rack::Request.new(env)
case req.path
when "/hello"
[200, {}, ["Hello"]]
else
@app.call(env)
end
end
end
use App
use Rack::Static
run -> (env) { [404, {}, ["Not found"]] }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment