rest path matching refactor