Skip to content

Commit

Permalink
test for fitting media types
Browse files Browse the repository at this point in the history
  • Loading branch information
guilhermesilveira committed Dec 13, 2009
1 parent cf8086a commit d34c1fd
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/restfulie/server/restfulie_controller.rb
Expand Up @@ -5,10 +5,7 @@ module Controller
def create

type = model_for_this_controller
unless Restfulie::MediaType.supports?(request.headers['CONTENT_TYPE']) ||
Restfulie::MediaType.media_type(request.headers['CONTENT_TYPE']) == type
return head 415
end
return head 415 unless fits_content(type, request.headers['CONTENT_TYPE'])

@model = Restfulie.from request
if @model.save
Expand All @@ -23,6 +20,11 @@ def model_for_this_controller
self.class.name[/(.*)Controller/,1].singularize.constantize
end

def fits_content(type, content_type)
Restfulie::MediaType.supports?(content_type) &&
Restfulie::MediaType.media_type(content_type) == type
end

end

end

0 comments on commit d34c1fd

Please sign in to comment.