Copy in ratelimit middleware as is from Swift

Change-Id: I6101545d222d29ece983b3ec6a7a020356f9ba47
Add notes & start to mark out changes needed

Change-Id: Ib77f2a394b63f238dcd16bfdc8c3a6f1af31504d