Skip to content

Instantly share code, notes, and snippets.

@rbq
Created April 22, 2013 21:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rbq/5438683 to your computer and use it in GitHub Desktop.
Save rbq/5438683 to your computer and use it in GitHub Desktop.
Problem: not_found doesn't work at all
# coding: utf-8
require 'rack/urlmap'
require File.join(File.dirname(__FILE__), 'app')
require File.join(File.dirname(__FILE__), 'api', 'v1')
routes = Rack::URLMap.new(
'/' => Sinatra::Application,
'/api/v1/' => ApiV1
)
set :environment, :production
run routes
require File.join(File.dirname(__FILE__), '..', 'config', 'environment')
require 'sinatra/base'
class ApiV1 < Sinatra::Base
before do
content_type :json
end
# snip
not_found do
Jbuilder.encode do |json|
json.error 'not found'
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment