A bit more refactoring for HttpApi