Refactoring request routing to use fnmatch function