Skip to content

Instantly share code, notes, and snippets.

@alexbaldwin
Last active December 28, 2015 12:59
Show Gist options
  • Save alexbaldwin/7504857 to your computer and use it in GitHub Desktop.
Save alexbaldwin/7504857 to your computer and use it in GitHub Desktop.
When using Middleman http://middlemanapp.com and HF&J http://typography.com together, the production checks fail. Use this Rack middleware to fix it. Code via @croaky.
require 'lib/rack_typography'
use Rack::Typography
module Rack
class Typography
# When switching to a new webfont, Hoefler Frere-Jones' typography.com runs
# an HTTP GET confirmation step against our font directory to see if we've
# installed it correctly. Because the directory returns 404 by default,
# we're unable to confirm the step. This middleware returns 200 OK for all
# possible /fonts/[:digits] routes that H&FJ may generate so that the
# confirmation step will pass.
def initialize(app)
@app = app
end
def call(env)
if env['REQUEST_PATH'] =~ /^\/fonts\/\d+$/
[200, { 'Content-Type' => 'text/html' }, ['']]
else
@app.call(env)
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment