various fixes to the rack middleware and grape resource