refactoring rest api