lib/flipper/api/action.rb in flipper-api-1.0.0 vs lib/flipper/api/action.rb in flipper-api-1.1.0

- old
+ new

@@ -17,10 +17,11 @@ end extend Forwardable VALID_REQUEST_METHOD_NAMES = Set.new([ + 'head'.freeze, 'get'.freeze, 'post'.freeze, 'put'.freeze, 'delete'.freeze, ]).freeze @@ -113,11 +114,11 @@ # status - http status code def json_response(object, status = 200) header 'content-type', Api::CONTENT_TYPE status(status) - body = JSON.dump(object) + body = Typecast.to_json(object) halt [@code, @headers, [body]] end # Public: Call this with an ErrorResponse::ERRORS key to respond # with the serialized error object as response body @@ -145,11 +146,15 @@ end private # Private: Returns the request method converted to an action method. + # Converts head to get. def request_method_name - @request_method_name ||= @request.request_method.downcase + @request_method_name ||= begin + name = @request.request_method.downcase + name == "head" ? "get" : name + end end # Private: split request path by "/" # Example: "features/feature_name" => ['features', 'feature_name'] def path_parts