foursqure middleware implementation