Fix middleware midfunc factory (don't initialize webAPI each time)