Project

General

Profile

« Previous | Next » 

Revision b2b47290

Added by Petr Chalupa almost 12 years ago

  • ID b2b4729059ff89327d7cd86d2e47664a2ce57c46

api v1 - render errors with rabl

better detection of permission failure in model
fix ApiConstraints
catch bad routes in api and return json

View differences:

lib/api_constraints.rb
class ApiConstraints
def initialize(options)
@version = options[:version]
@default = options[:default]
@default = options.has_key?(:default) ? options[:default] : false
end
def matches?(req)
@default || req.headers['Accept'].each {|h| return true if h.grep("version=#{@version}")}
req.accept =~ /version=([\d\.]+)/
if (version = $1) # version is specified in header
version == @version.to_s # are the versions same
else
@default # version is not specified, match if it's default version of api
end
end
end

Also available in: Unified diff