lib/metatron/sync_controller.rb in metatron-0.4.0 vs lib/metatron/sync_controller.rb in metatron-0.4.1
- old
+ new
@@ -7,18 +7,13 @@
headers "Access-Control-Allow-Methods" => ["POST"]
halt 200
end
post "/" do
- # TODO: move this to Sinatra's `etag` helper when Metacontroller is RFC compliant
- if (provided_etag = calculate_etag) &&
- (match_header = request.env["HTTP_IF_NONE_MATCH"]) &&
- match_header.split(/,\s?/).include?("\"#{provided_etag}\"")
- halt 304
+ if (provided_etag = calculate_etag)
+ etag provided_etag
end
- # If the etag is available, use it, otherwise proceed with the sync
- headers "ETag" => "\"#{provided_etag}\"" if provided_etag
data = sync
data[:children] = data[:children]&.map { |c| c.respond_to?(:render) ? c.render : c }
halt(data.to_json)
end