Skip to content

Instantly share code, notes, and snippets.

@hlb
Last active December 9, 2015 19:28
Show Gist options
  • Save hlb/4316999 to your computer and use it in GitHub Desktop.
Save hlb/4316999 to your computer and use it in GitHub Desktop.
class PHPHandler
def initialize(app)
@app = app
end
def call(env)
if env["PATH_INFO"] =~ /\/$/
env["PATH_INFO"] += "index.php"
end
if env["PATH_INFO"] =~ /\.php$/
php_path = env["PATH_INFO"][1..-1]
body = %x{php #{php_path}}
[200, {"Content-Type" => "text/html"}, [body]]
else
status, headers, body = @app.call(env)
[status, headers, body]
end
end
end
use PHPHandler
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment